407761: GYM102890 L Let's count words

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

L. Let's count wordstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

Two words $$$W_1$$$ and $$$W_2$$$ are said to be generated from the same word $$$W$$$, if the three words have the same length $$$L$$$, and you can read both $$$W_1$$$ and $$$W_2$$$ from $$$W$$$ reading exactly $$$L$$$ letters starting at a position in $$$W$$$. If while reading from $$$W$$$ you get to the end of the word you start again from the first position. For example rdwo and ordw are both generated from the same word word, the first one is if you start reading from the third position of the word, the second one is if you start from the second position. A word $$$W$$$ is generated from the same word $$$W$$$ as you can read the word starting at the first position of it.

Given a list of $$$N$$$ words, can you find how many different generator words $$$W$$$ were used to create the list?

Input

The first line of input contains a single integer $$$N$$$ ($$$1 \leq N \leq 100$$$), representing the number of words in the list. The second and last line of input contains $$$N$$$ strings separated by a space, representing the $$$N$$$ words in the list. Each word in the list will contain only lower case letters from the english alphabet and will have no more than $$$100$$$ letters.

Output

Print a single line with an integer, representing the number of different generator words $$$W$$$ that were used to create the list.

ExampleInput
7
word icpc rdwo dwor ordw pcic ccpi
Output
3

加入题单

算法标签: