IOI '06 - Merida, Yucatan, Mexico
Deciphering the Mayan writing has proven to be a harder task than anticipated by the early investigations. After almost two hundred years, very little of it was actually understood. It has been only in the last three decades that real advances have been made.
Mayan writing is based on small drawings known as glyphs which represent sounds. Mayan words are normally written as glyphs put together at various positions.
One of several problems in deciphering Mayan writing arises in the order of reading. When placing several glyphs in order to form a word, Mayan writers sometimes decided the position based more on their own esthetic views than on any particular rule. This leads to the fact that, even though the sound for many glyphs is known, sometimes archaeologists are not sure how to pronounce a written word.
The archaeologists are looking for a special word
Write a program that, given the glyphs for
Input Specification
The first line of input contains two space-separated integers:
The second line contains
The third line contains
Output Specification
One integer on a single line, the number of possible appearances of
Grading
In some test cases worth
Sample Input
4 11
cAda
AbrAcadAbRa
Sample Output
2
Comments