Size of the Dictionary

Time limit2sMemory limit128 MB

Problem

Jungyu wants to invent a new language called Jomal. First, Jungyu writes down a list of all the words that form the foundation of Jomal. Each word on this list is called a base word.

Using the base words, Jungyu now builds new words to complete the Grand Jomal Dictionary. A word appears in the Grand Jomal Dictionary if it satisfies at least one of the following conditions.

  • The word itself is a base word.
  • The word can be split into two parts so that the front part is a prefix of some base word (the whole word counts as a prefix) and the back part is a suffix of some base word (the whole word counts as a suffix). Both parts must be non-empty.

Determine how many distinct words the Grand Jomal Dictionary contains under this rule.

Input

The first line contains the number of base words n (1 ≤ n ≤ 10 000). Each of the next n lines contains one base word. Every base word consists only of lowercase letters and has length between 1 and 40, inclusive.

Jungyu is lazy and did not check whether the list contains duplicate words, so the same word may appear several times; identical words are treated as one.

Output

Print, on a single line, the number of distinct words in the Grand Jomal Dictionary.