In the hidden country of Lapatrecta, an age old custom was followed to ensure that no outsider ever entered their country undetected. The security measure, though simple, was an effective one. Every person born in Lapatrecta had the initials of all his forefathers included in front of his name. Every once in a while, certain families became very famous and the initials of their ancestors were dropped from the names of all their descendants. Thus, there existed a nice homogeneity in the names of the people of Lapatrecta.

Now, a royal ball was organized at the behest of the Queen of Lapatrecta and all citizens were cordially invited to the event. The ball was being held to chop off the initials of the ancestors of the  most distinguished family of the country. The Queen set the following 2 criteria for determining the most distinguished family from amongst the invitees:


1.	The family must have more than 1 member living.
2.	The length of the ancestor list of the family must be as long as possible.


For example:


For 3 people:
APJQ Ravi
APJRS Rahul
PJQ Bharat


The following observations hold:
APJQ Ravi was of the same family as APJ Rahul but PJQ Bharat was not of the same family.


The length of the ancestor list for Ravi and Rahul was 3 whereas Bharat has an ancestor length of 0 as there is no other member of his family living.  However, if there existed a person named PJ Varun, Bharat and Varun would both have an ancestor list length of 2.


As a member of the Royal Court of Lapatrecta, you have been entrusted the task of determining the length of the ancestor list that will be chopped off by the Queen. You will be provided data in the following format:


Input
Line 1: N – The number of people coming to the ball
Line 2-N+1: The initials list of all the people coming to the ball. No initials list is longer than 100 characters.


Output
Line 1: The length of the longest ancestor list.

Example

Input:
3
APJQ
APJRS
PJQ

Output:
3
N = int (raw_input())

words = []
maxDep = 0

def dfs(dic, depth):
    global maxDep
    if dic['__a'] > 1:
        if depth > maxDep:
            maxDep = depth
    for key in dic.keys():
        if key!='__a':
            if dic[key]['__a'] > 1:
                dfs(dic[key], depth+1)
    
dic = {}
dic['__a'] = 0
for i in range(N):
    words.append(raw_input())
    
    
    curDic = dic
    
    for l in range(len(words[i])):
        if not curDic.has_key(words[i][l]):
            curDic[words[i][l]] = {}
            curDic[words[i][l]]['__a'] = 0
        curDic['__a'] += 1
        curDic = curDic[words[i][l]]
dfs(dic, 0)
print maxDep