The only valid masks are those which indicate a prefix length. Thus, valid masks must begin with a string of one bits, then change to a string of zero bits. Since each element in the dotted quad syntax represents one byte, or eight bits, it follows that there are only a handful of eight bit numbers that fit this requirement. In fact, there are only nine such numbers, and they are shown in this diagram.
If someone tries to convince you that a dotted-quad number containing something other than these nine numbers is a valid subnet mask, politely demur and refer them to www.freesoft.org.
I suggest you familiarize yourself with these nine numbers and their binary representations. They reoccur so often that if you do not have them memorized now, you soon will.