Solve equation


Description

You're given a string of lower-case Latin letters. Your task is to find the length of its longest substring that can be met in the string at least twice. These occurrences can overlap (see sample test 2).

Input

The first input line contains the string. It's guaranteed, that the string is non-empty, consists of lower-case Latin letters, and its length doesn't exceed 100.

Output

Output one number — length of the longest substring that can be met in the string at least twice.

Sample Input

Input
abcd
Output
0
Input
ababa
Output
3
Input
zzz
Output
2


</pre><pre name="code" class="cpp">#include<iostream>
#include<cstring>
#include<algorithm>
#include<map>
#include<cstdio>
#include<string>
using namespace std;
map<string,int>num;
int main()
{
    string s,name;
    int i,j,k,n;
    cin>>s;
    n=s.size();
    for(k=1;k<=n;k++) {
        for(i=0;i+k<=n;i++) {
            name="";
            for(j=i;j<i+k;j++) {
                name=name+s[j];
            }
            num[name]++;
            if(num[name]>1) break;
        }
        if(i+k>n) break;
    }
    cout<<k-1<<endl;
    return 0;
}





你可能感兴趣的:(Solve equation)