How many string exist of length 2M with 9 characters and without repeating a character more than M times? You can suppose that M is greater than 4.
I know that my english is really bad so i'll give you some examples.
AABBCCDDEE is a valid string
AAAAAADEEE is not a valid string (A is repeated more then 5 times).
AA is not a valid string as it is not of length 2M
ZZ is not a valid string as you can have 9 different chars :A,B,C,D,E, F, G, H, I.
p.s. Is not homework: the original question is really different, I'm asking you a simplified model.