Polish version    English version  
  History of OI -> VII OI 1999/2000 -> Problems


 News
 About Olympic
 History of OI
XVII OI 2009/2010
XVI OI 2008/2009
XV OI 2007/2008
XIV OI 2006/2007
XIII OI 2005/2006
XII OI 2004/2005
XI OI 2003/2004
X OI 2002/2003
IX OI 2001/2002
VIII OI 2000/2001
VII OI 1999/2000
Stage III - results
Stage II - results
Stage I - results
Problems
Regulations
Organization
Hints
Schedule
Stats
VI OI 1998/1999
V OI 1997/1998
IV OI 1996/1997
III OI 1995/1996
II OI 1994/1995
I OI 1993/1994
 OI books
 National team
 Olympic camps
 Photo gallery
 Links
 SIO
 MAIN
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:

  • reads the sequence of words from text file POW.IN,
  • counts the length of the longest word occuring as a coherent fragment in every word given,
  • writes the result to the text file POW.OUT.

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



Print friendly version