Niebieskie ksi.eczki
VII Olimpiada Informatyczna 1999/2000

Task: POW
Author: Adam Malinowski
Repetitions

III stage contest  

A sequence of words over alphabet ['a',..,'z' ] is given. The length of longest word occuring as a coherent fragment in every word given is to be found.

Task

Write a program, which:

Input

In the first line of the text file POW.IN there is an integer n, where 1 <= n <= 5 is the number of words. In each of the next n lines there is one word formed from small letters of English alphabet ['a',..,'z']. The length of each word is at least 1, but not greater than 2000.

Output

The text file POW.OUT should consist of exactly one line containing a single integer equal to the length of the longest word occuring as the coherent fragment in every word given.

Example

For the input file POW.IN:
3
abcb
bca
acbc
the correct result is the output file POW.OUT
2