We need to find the number of different configurations possible for memory and each of these will be a state in FSM. (At any time memory will be in one configuration and in next instance it either remains same or goes to a different configuration)
A word is of n bits. And we have m such words. So, total number of bits = m*n.
We need a separate state for each bit combination. So, no. of states = 2mn.