The other user already answered your question but I'd still like to reiterate, elaborate, and suggest a MNEMONIC.
Consider two matrices [math] Y [/math] and [math] Z [/math] , whose entries are all complexes (that is, complex numbers, of which natural numbers, real numbers and so on, are all specific examples) and thus the crunching is amenable to the usual arithmetic. Let us reiterate along the lines of what the above poster wrote: Let us specify that the number of rows in Y is m, the number of columns in Y is n, the number of rows in Z is a, and the number of columns in Z is b. We may if we wish, write a subscript for any matrix at our convenience, to specify these quantities. By convention, a matrix's number of rows is ALWAYS written first, and a matrix's number of columns is ALWAYS written second. Thus our two matrices can be written as [math] Y_{m \times n} [/math] and [math] Z_{a \times b} [/math] . By definition (hopefully, obviously) all of m, n, a and b are natural numbers.
As the other user as-good-as-said, matrix multiplication is only defined when the number of COLUMNS in the first (left) matrix, is equal to the number of ROWS in the second (right) matrix. Thus, in order for the the product [math] Y_{m \times n} Z_{a \times b} [/math] to be evaluated, defined, worth doing and not looking stupid in trying, we immediately require that n = a, just as the above user said. This allows the arithmetic to work out in a well-defined way, you just have to be careful to do your boring bookkeeping while crunching.
FURTHER, continuing with the above, the RESULT of such a matrix multiplication, IS a matrix whose number of rows is EQUAL to the number of rows in the first matrix, and whose number of columns is EQUAL to the number of columns in the second. Thus, if n = a, then the above product is indeed defined, and may be expressed thus, as some matrix [math] W [/math] : [math] Y_{m \times n} Z_{a \times b} = W_{m \times b} [/math]
cont.