Proof:
this is a nice problem! i think by that you mean the field of real numbers well, you really don't need your ground field to be so i'll assume that is any field and and are
and matrices respectively, with entries in let be the linear transformations corresponding to and respectively, i.e. and
are defined by for all and for all
claim. where means "dimension of the kernel".
proof. define by for all note that is well-defined because if , then and thus
it's obvious that is linear and therefore, by the rank-nulity theorem, we have
but and
now solving your problem is easy: applying the above claim and the rank-nulity theorem we have: