Preparando MOJI

Suffix Subgroup

2000ms 262144K

Description:

You are given a group of n strings: s1, s2, ..., sn.

You should find a subgroup si1, si2, ..., sik (1 ≤ i1 < i2 < ... < ik ≤ n) of the group. The following two conditions must hold:

  • there exists a string t such, that each string from found subgroup is its suffix;
  • the number of strings in the found subgroup is as large as possible.

Your task is to print the number of strings in the found subgroup.

Input:

The first line contains an integer n (1 ≤ n ≤ 105) — the number of strings in the group. Each of the next n lines contains a string. The i-th line contains non-empty string si.

Each string consists only from lowercase Latin letters. The sum of all strings si doesn't exceed 105.

Output:

Output a single integer — the number of strings in the found subgroup.

Sample Input:

6
bb
bb
b
aaa
aa
z

Sample Output:

3

Note:

Look at the test sample. The required subgroup is s1, s2, s3.

Informação

Codeforces

Provedor Codeforces

Código CF345G

Tags

*specialstrings

Submetido 0

BOUA! 0

Taxa de BOUA's 0%

Datas 09/05/2023 08:46:39

Relacionados

Nada ainda