Time limit
1s
Memory limit
128 MB
Two words made of uppercase English letters are said to have the same composition when both conditions hold.
For instance, "DOG" and "GOD" have the same composition because each contains one 'D', one 'G', and one 'O'. In contrast, "GOD" and "GOOD" do not have the same composition because 'O' appears once in "GOD" and twice in "GOOD".
Two words are similar if they already have the same composition, or if one word can be made to have the same composition as the other by adding one letter, deleting one letter, or replacing one letter with another.
For instance, "DOG" and "GOD" are similar because they have the same composition. "GOD" and "GOOD" are also similar because adding one 'O' to "GOD" gives the same composition as "GOOD". However, no single addition, deletion, or replacement in "DOG" can make it have the same composition as "DOLL", so those two words are not similar.
Given several distinct words, determine how many of the remaining words are similar to the first word.
The first line contains the number of words N. Each of the next N lines contains one word.
Every word consists only of uppercase English letters. There are at most 100 words, and each word has length at most 10.
Print the number of words among the remaining words that are similar to the first word.