Similarity#240

Similarity

0.5 seconds
64 megabytes
Medium

Substitution in the Latin alphabet is a one-to-one mapping of each letter to another unique letter. Two words of the same length are called similar if there is a substitution that transforms one word into the other. For example, the words and , as well as and , are similar. However, and , or and , are not similar.

Clearly, if two words are similar to a third word, then they are also similar to each other. Thus, any set of words can be partitioned into a certain number of groups of mutually similar words. The number of such groups is called the similarity index. For example, the similarity index of the set , , , , is , because the words and form one group, and , , and form the other.

Given words, each of length , determine the similarity index of this set of words.

Input

The first line contains the integer — the number of words. The next lines each contain one word. Each word is any sequence of lowercase Latin letters. 0 < N \leq 5000. 0 < L \leq 50.

Output

Output a single integer — the similarity index of the given set of words.

Examples

Example 1

Loading
Loading