Problem1532--Magic Password

1532: Magic Password

[Creator : ]
Time Limit : 1 sec  Memory Limit : 128 MB

Description

Each password is a given English word list containing only lowercase letters. Each word contains at least 1 letter and up to 75 letters. If in a table of one or more words, except for the last one, each word is contained by a subsequent word, ie, the previous word is the prefix of the next word, the word list is a Word chain. For example, the following words form a word chain:


i
Int
Integer


But the following words do not form a word chain:


Integer
Intern


Now all you have to do is take some words out of a given list of words and form the longest word chain, which is the chain of words that contains the most words. Count the number of words and get the password. In other words, the password is the number of words included in the longest word chain...

Input

The first row of words in the list of words N (1<=N<=2000), each row below has one word, arranged in lexicographic order, there are no duplicate words in the middle.

Output

An integer represents the password

Sample Input Copy

5
i
int
integer
intern
internet

Sample Output Copy

4

Source/Category