#include<bits/stdc++.h>
using namespace std;
int main()
{
string s;
cin>>s;
for(int l=s.size()-1;l>=0;--l)
for(int i=0;i<s.size()-l;++i)
if(s.rfind(s.substr(i,l))!=i)
{
cout<<l;
return 0;
}
cout<<0;
}

#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;

main(){
	char x[100];
	scanf("%s",x);
	int i,j,t,l=0;

	for(i=0;i<strlen(x);i++){
		for(j=i+1;j<strlen(x);j++){
			t=0;

			while(x[i+t] == x[j+t]){
				t++;
			}

			l=max(l,t);
			/*if(x[i]==x[j]){
				t=j-i;
				printf("%d\n",)
				break;
			}*/
		}
	}

	printf("%d",l);

	/*int s=0;

	for(i=0;i<strlen(x);i++){
		for(j=i+1;j<strlen(x);j++){
			if(x[i]==x[j]){
				if(h==j-i){
					s+=1;
				}
				break;
			}
		}
	}

	printf("%d",s);
	*/

	return 0;
}

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
	string s;int i,j,res=0;
	cin>>s;int n=s.length();
	for(int l=1;l<=n;l++)
	{
		vector<string> v;
		for(i=0;(i+l-1)<n;i++)
		v.push_back(s.substr(i,l));
		sort(v.begin(),v.end());
		for(i=0;i<v.size()-1;i++)
		{
			if(v[i]==v[i+1])
			{
				res=l;
				break;
			}
		}
	}
	cout<<res;
	return 0;
}

#include <iostream>
#include <cstdlib>
#include <string.h>
using namespace std;
int main(){
    string s;
    int i , j , a = 0 , max = 0;
    cin>>s;
    for(i = 0 ; i < s.length() ; i++)
          for(j = i + 1 ; j < s.length() ; j++){
                 a = 0;
                 while(s[i + a] == s[j + a])
                      a+=1;
                 if(a > max)
                     max = a;
          }
        cout<<max;
        return 0;
}

#include<bits/stdc++.h>
using namespace std;
int n,i,l,j,d;
char s[110];
bool q;
int main()
{
	gets(s);
	n=strlen(s);
	for(l=n-1;l>=1;l--){
		for(i=0;i+l<=n;i++) for(j=i+1;j+l<=n;j++){
			q=true;
			for(d=0;d<l;d++)if(s[i+d]!=s[j+d]){
				q=false;
				break;
			}
			if(q)
			{
				printf("%d\n",d);
				return 0;
			}
		}
	}
	puts("0");
	return 0;;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s,s1;
	cin>>s;
	int len=s.size();
	for (int d=len-1;d>=1;d--)
	{
	  for(int i=0;i<=len-d;i++)
	   {
			s1=s.substr(i,d);
			int x=s.find(s1,i+1);
			if(x!=string::npos)
	 		 {cout<<d<<endl;return 0;}
	   }
	}
	 cout<<0<<endl;
  return 0;
}

#include<iostream>
#include<algorithm>
using namespace std;
#define maxn 150
char str[maxn];
int maxx;
struct node
{
	int now, next;
} d[maxn];
int val[maxn][2], c[maxn], Rank[maxn], SA[maxn], pos[maxn], x[maxn];
int h[maxn];
int height[maxn];
int n;
inline void add_value(int u, int v, int i)
{
	d[i].next = c[u];
	c[u] = i;
	d[i].now = v;
}
inline void radix_sort(int l, int r)
{
	for (int k = 1; k >= 0; k--)
	{
		memset(c, 0, sizeof(c));
		for (int i = r; i >= l; i--)
			add_value(val[pos[i]][k], pos[i], i);
		int t = 0;
		for (int i = 0; i <= maxn; i++)
		for (int j = c[i]; j; j = d[j].next)pos[++t] = d[j].now;
	}
	int t = 0;
	for (int i = 1; i <= n; i++)
	{
		if (val[pos[i]][0] != val[pos[i - 1]][0] || val[pos[i]][1] != val[pos[i - 1]][1])t++;
		Rank[pos[i]] = t;
	}
}
inline void get_suffix_array()
{
	int t = 1;
	while (t / 2 <= n)
	{
		for (int i = 1; i <= n; i++)
		{
			val[i][0] = Rank[i];
			val[i][1] = (((i + t / 2 <= n) ? Rank[i + t / 2] : 0));
			pos[i] = i;
		}
		radix_sort(1, n);
		t *= 2;
	}
	for (int i = 1; i <= n; i++)
		SA[Rank[i]] = i;
}
inline void get_common_prefix()
{
	memset(h, 0, sizeof(h));
	for (int i = 1; i <= n; i++)
	{
		if (Rank[i] == 1)h[i] = 0;
		else
		{
			int now = 0;
			if (i > 1 && h[i - 1] > 1)now = h[i - 1] - 1;
			while (now + i <= n&&now + SA[Rank[i] - 1] <= n&&x[now + i] == x[now + SA[Rank[i] - 1]])
				now++;
			h[i] = now;
		}
	}
	for (int i = 1; i <= n; i++)
		height[Rank[i]] = h[i],maxx=max(maxx,height[Rank[i]]);
}
int main()
{
	scanf("%s", str);
	n = strlen(str);
	for (int i = 1; i <= n; i++)
		x[i] = Rank[i] = (int)str[i - 1];
	get_suffix_array();
	get_common_prefix();
	printf("%d\n ", maxx);
	return 0;
}

#include<bits/stdc++.h>
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v)  (v).begin(),(v).end()
using  namespace std;
typedef pair<int, int>ii;
typedef long long int64;
typedef vector<int> vi;
template<class T>T abs(T x) {return x>0?x:(-x);}
template<class T>T sqr(T x) {return x*x;}
int main()
{
	string s;
	cin>>s;
	int res=0;
	for(int l=1;l<=sz(s);l++){
		vector<string> v;
		for(int i=0;i+l-1<sz(s);i++)
		v.pb(s.substr(i, l));
		sort(all(v));
		for(int i=0;i<sz(v)-1;i++)
		  if(v[i]==v[i+1]){
		  	res=l;
		  	break;
		  }
	}
	cout<<res<<"\n";
	return 0;
}

#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	string str = "";
	cin >> str;
	int len = str.length();

	int res = 0;
	for (int i = 0; i < len - 1; i++ ){
		for (int j = i + 1; j < len; j++ ){
			int k = 0;
			while (str[i+k] == str[j+k] ){
				k++;
			} // end while
			res = max (res, k );
		} // end for
	} // end for
	cout << res << endl;

	return 0;
}

#include<cstdio>
#include<cstring>
char str[110];
int main() {
    int len, t, _max=0;
    scanf("%s", str);
    len=strlen(str);
    for(int i=0; i<len; i++)
        for(int j=i+1; j<len; j++)
		{
            t=0;
            while(str[i+t]==str[j+t]) t++;
            if(t>_max) _max=t;
        }
    printf("%d", _max);
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
string s;
set<string> all;
int main()
{
	cin>>s;
	for(int i=s.size()-1;i>0;i--)
	{
		all.clear();
		for(int j=0;j+i<=s.size();j++)
			all.insert(s.substr(j,i));
		if(all.size()!=s.size()-i+1)
		{
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<0<<endl;
	return 0;
}

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int kmp_arr[10000];
char arr[10000];
int ans[10010], idx = 0;
void pre_kmp(char p[], int len)
{
    kmp_arr[0] = kmp_arr[1] = 0;
    int maxnum = 0;
    for(int j = 0, i = 1; i < len; ++i)
    {
        j = kmp_arr[i];
        while(j&&p[i] != p[j]) j = kmp_arr[j];
        if(p[i] == p[j]) ++j;
        kmp_arr[i+1] = j;
        if(kmp_arr[i+1] > maxnum) maxnum = kmp_arr[i+1];
    }
    //sort(kmp_arr,kmp_arr+len+1);
    //ans[idx++] = kmp_arr[len];
    ans[idx++] = maxnum;
}
int main()
{
    scanf(" %s",arr);
    int len = strlen(arr);
    for(int i = 0; i < len; ++i)
    {
        pre_kmp(arr+i,len-i);
        memset(kmp_arr,0,sizeof(len-i+1));
    }
    sort(ans,ans+idx);
    printf("%d\n",ans[idx-1]);
	return 0;
}

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int kmp_arr[10000];
char arr[10000];
int ans[10010], idx = 0;
void pre_kmp(char p[], int len)
{
    kmp_arr[0] = kmp_arr[1] = 0;
    for(int j = 0, i = 1; i < len; ++i)
    {
        j = kmp_arr[i];
        while(j&&p[i] != p[j]) j = kmp_arr[j];
        if(p[i] == p[j]) ++j;
        kmp_arr[i+1] = j;
    }
    sort(kmp_arr,kmp_arr+len+1);
    ans[idx++] = kmp_arr[len];
}
int main()
{
    scanf(" %s",arr);
    int len = strlen(arr);
    for(int i = 0; i < len; ++i)
    {
        pre_kmp(arr+i,len-i);
        memset(kmp_arr,0,sizeof(len-i+1));
    }
    sort(ans,ans+idx);
    printf("%d\n",ans[idx-1]);
	return 0;
}

//#pragma comment(linker,"/STACK:16777216") /*16Mb*/
//#pragma comment(linker,"/STACK:33554432") /*32Mb*/
#define _CRT_SECURE_NO_DEPRECATE
#include<iostream>
#include<numeric>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<memory>
#include<string>
#include<vector>
#include<cctype>
#include<list>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
using namespace std;

typedef unsigned long long      ui64;
typedef long long               i64;
typedef vector<int>             VI;
typedef vector<bool>            VB;
typedef vector<VI>              VVI;
typedef vector<string>          VS;
typedef pair<int,int>           PII;
typedef map<string,int>         MSI;
typedef set<int>                SI;
typedef set<string>             SS;
typedef map<int,int>            MII;
typedef pair<double,double>     PDD;

#define PB                      push_back
#define MP                      make_pair
#define X                       first
#define Y                       second
#define FOR(i, a, b)            for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b)           for(int i = (a) - 1; i >= (b); --i)
#define CLEAR(a, b)             memset(a, b, sizeof(a))
#define SZ(a)                   int((a).size())
#define ALL(a)                  (a).begin(), (a).end()
#define RALL(a)                 (a).rbegin(), (a).rend()
#define INF                     (2000000000)

int main()
{
    string s;
    cin >> s;
    int res = 0;
    FOR(i,0,SZ(s)) {
        FOR(j,1,SZ(s)) {
            if( i+j >SZ(s))
                continue;
            string t = s.substr(i,j);
            int c = 0;
            FOR(k,0,SZ(s)-j+1)
                if( s.substr(k,j)==t ) c++;
            if( c>=2 )
                res = max(res, j);
        }
    }
    cout << res << endl;
    return 0;
}

#include <bits/stdc++.h>

using namespace std;
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define ff first
#define setp setprecision(12)<<fixed
#define ss second
#define fori(v) for(int i=0; i<v; i++)
#define forj(v) for(int j=0; j<v; j++)
#define fork(v) for(int k=0; k<v; k++)
#define forl(v) for(int l=0; l<v; l++)
#define fort(v) for(int t=0; t<v; t++)
#define forz(v) for(int z=0; z<v; z++)
#define lli long long int
#define double long double
#define MAX 50100
#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define so(a) sort((a).begin(), (a).end())
#define reset(a, v) memset((a), v, sizeof(a))
int main()
{string a,b,c,d;
    cin>>a;
    int t;
    for( t=a.size();t>=1;t--) {
        vector<string>n;
        for (int i = 0; i < a.size() - t+1; i++) {
            b = a.substr(i, t);
            n.push_back(b); }
        int y=n.size();
        so(n);
        n.erase(unique(all(n)),n.end());
        if(y!=n.size()) {
            cout <<t<< endl;
        break;}

    }
    if(t==0)
        cout<<t<<endl;
}

#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
using namespace std;
string s;
int maxx=-1;
char b[101];
int main(){
	cin>>s;
	maxx=-1;
	int lens=s.size();
	for(int i=0;i<s.size();i++){
		for(int j=i;j<s.size();j++){
			int lenb=-1;
			for(int k=i;k<=j;k++){
				b[++lenb]=s[k];
			}
			int tot=0;
			for(int k=0;k<lens;k++){
				int c=0;
				for(int l=0;l<lenb;l++)
					if(s[k+l]!=b[l])  c++;
				if(!c) tot++;
			}
			if(tot>=2&&lenb>maxx) maxx=lenb;
		}
	}
	if(maxx==-1) printf("0");
	else printf("%d",maxx);
	return 0;
}

# include <bits/stdc++.h>
using namespace std;
set<string>s;
int ans=0;
int main() {

	string a;
	cin>>a;
	int l=a.length();
    for(int i=0;i<l;i++)
    {
        string b;

        for(int j=i;j<l;j++)
        {
            b+=a[j];
            if(s.find(b)!=s.end())ans=max(ans,(int)b.length());
            s.insert(b);
        }
    }
    cout<<ans;
}

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define pb push_back
#define pi acos(-1)
#define P pair<int,int>
#define fi first
#define se second
#define si signed
#define sc(x) scanf("%lld",&(x));
int n,m;
char A[105];
int nxt[105];
void getNext(char* p)
{
    int pLen = strlen(p);
    nxt[0] = -1;
    int k = -1;
    int j = 0;
    while (j < pLen - 1)
    {
        //p[k]表示前缀，p[j]表示后缀
        if (k == -1 || p[j] == p[k])
        {
            ++k;
            ++j;
            nxt[j] = k;
        }
        else
        {
            k = nxt[k];
        }
    }
}
void getNxt(char A[])
{

    int len = strlen(A);
    int i=1,j=0;
    nxt[0]=-1;

    while(i<len)
    {
        if(A[i]==A[j])j++,i++,nxt[i]=j;
        else
        {
            j=nxt[j];
            if(j==-1){
                i++;j++;
            }
        }

    }

}
signed main()
{
    scanf("%s",A+1);
    int len=strlen(A+1);
    int ans = 0;
    for(int i=1; i<len; i++)
    {

        getNxt(A+i);

        for(int j=0; j<=len-i+1; j++)
        {
            //cout<<nxt[j]<<endl;
            ans= max(nxt[j],ans);
        }
    }
    cout<<ans<<'\n';

}

#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define ll unsigned long long int
#define test long int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
#define mm 1000000007
int ans;
bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int binaryExponentiation(int x, int n) //function to calculate x raise to power n
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x;
		x = x * x;
		n = n / 2;
	}
	return result;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-______________________________________________________________________________
	string s;
	cin >> s;
	map<string, int>mp;
	for (int i = 0; i <
	        s.size(); i++)
	{
		for (int j = 1; j + i <= s.size(); j++)
		{
			mp[s.substr(i, j)]++;
			if (mp[s.substr(i, j)] > 1)ans = max(ans, j);
		}
	}
	cout << ans << endl;

	return 0;
}

#include<bits/stdc++.h>
using namespace std;

const int N = 100 + 5;
int n;
char s[N];

int main(){
    scanf("%s", s);
    int n = strlen(s);
    int ans = 0;

    for(int i = 0; i < n; i++){
        for(int l = i+1; l < n; l++){
            int len = 0;
            while( i + len < n and l + len < n and s[i+len] == s[l+len])
                len += 1;
            if(ans!= len)
                ans = max(ans, len);
        }
    }

    printf("%d\n", ans);
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int n;
int m;
string w;
set<string> all;

int main() {
	cin>>w;
	int n=w.size ();
	for (int i=n-1; i>0; i--) {
		all.clear ();
		for (int j=0; j+i<=n; j++) all.insert (w.substr (j,i));
		if (all.size()!=n-i+1) {
			cout<<i<<endl;
			return 0;
		}
	}
	cout <<"0"<< endl;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
int main(void){
	int N,i,j,k;
	string s;
	cin>>s;
	N=s.length();
	int ans=0;
	REP(i,N) REP(j,N) if(i<j){
		for(k=0;;k++) if(i+k>=N || j+k>=N || s[i+k]!=s[j+k]) break;
		ans=max(ans,k);
	}
	cout<<ans<<endl;
	return 0;
}

#include<iostream>
typedef unsigned long long ull;
using namespace std;
int n,cnt,m;
int main(){
	for(int i=1;i<=2e10;i++) cnt++,cnt--,cnt*=2,cnt/=2,cnt++,cnt--;
	string s;
	cin>>s;
	int qqq=s.size();
	for(int i=0;i<s.size();i++){
		for(int j=1;j<qqq-i;j++){
			string tmp=s.substr(i,j);
//			\int aaa=s.find(tmp,i);
//			cout<<s.find_first_of(tmp,i)<<endl;
			if(s.find(tmp,i+1)!=i&&s.find(tmp,i+1)!=-1){
				m=max(m,j);
			}
		}
	}
	cout<<m;
}

#include<bits/stdc++.h>
using namespace std;
string s;
int main(){
	string s;
        while(cin>>s){
                int ss=s.size();
                int maxn=0;
                for(int i=0;i<ss;i++){
                        for( int j=i+1;j<ss;j++){
                                int m=0;
                                while(s[i+m]==s[j+m]){
                                        m++;
                                }
                                maxn=max(m,maxn);
                        }
                }
                cout<<maxn<<endl;
        }
        return 0;
}

#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

int main(){
 string s;
 cin>>s;
 int i,len=s.length();
 for(i=len-1;i>0;i--)
 {
  size_t pos;
  for(int j=0;j<len-i+1;j++){
   string temp=s.substr(j,i);
   pos=s.find(temp);
   if(pos!=string::npos) pos=s.find(temp,pos+1);
   if(pos!=string::npos) {cout<<i; return 0;}

  }

 }
 cout<<i;
 return 0;
}

#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_DEPRECATE

#pragma comment(linker, "/STACK:64000000")

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

	string s;
	int len, m = 0;

	cin >> s;
	len = s.length();

	for (int i = 0; i < len; ++i)
	{
		for (int j = i + 1; j < len; ++j)
		{
			int p = 0;
			while (s[i + p] == s[j + p]) p++;
			m = max(p, m);
		}
	}
	cout << m;

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
long long n;
string s,ss,s1;
void doc()
{
    cin>>s;
    n=s.length();
}
void xuly()
{
    for(int i=n-1;i>=1;i--)
    {
        for(int j=0;j<=n-i;j++)
        {
            ss=s;
            s1=ss.substr(j,i);
            ss[j]='.';
            if (ss.find(s1)!=-1) {cout<<i;return;}
        }
    }
    cout<<0;
}
int main()
{
    doc();
    xuly();
}

#include<bits/stdc++.h>
using namespace std;
char str[101];
int len,t,maxn;
int main()
{
    cin>>str;
    len=strlen(str);
    for(int i=0;i<len;i++)
    {
    	for(int j=i+1;j<len;j++)
		{
            t=0;
            while(str[i+t]==str[j+t]) t++;
            if(t>maxn) maxn=t;
        }
	}
    cout<<maxn<<endl;
    return 0;
}

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main (){
  int max=0;
  string s;
  cin>>s;
  vector<string> v;
  for(int i=0;i<=s.size();i++){
    for(int j=0;j<=s.size()-i;j++){
      v.push_back(s.substr(i,j));
    }
  }
 sort(v.begin(),v.end());
 for(int i=v.size()-1;i>0;i--){
if(v[i]==v[i-1]){
  if(v[i].size()>max){
    max=v[i].size();
  }
}
}
 cout<<max;
}

#include<iostream>
#include<string>
using namespace std;
int main()
{
    string str;
    cin>>str;
    for(int k=str.size();k;k--)
    {
        for(int i=1;i<=str.size()-k+1;i++)
        {
            int l=0;
            string s=str.substr(i-1,k);
            for(int j=1;j<=str.size()-k+1;j++)
            {
                l+=(s==str.substr(j-1,k));
            }
            if(l>=2)
            {
                cout<<k<<endl;
                return 0;
            }
        }
    }
    cout<<0<<endl;
    return 0;
}

#include <bits/stdc++.h>
#define pb push_back
#define sz(x) x.size()
#define F first
#define S second
#define mp make_pair
#define ll long long
#define sqr(x) ((x)*(x))
using namespace std;
int a[100010], b[100010], c[100010];
ll mn=1e9, mx=-1e9, ans, cnt, sm;
bool ok, okk, used[1000010], use[10];
int main(){

    //freopen ("i.txt","r",stdin);
    //freopen ("o.txt","w",stdout);

    string s, str;
    cin>>s;
    int x=sz(s);
    for(int j=x;j>0;j--){
    	set <string> st;
    	for(int i=0;i<=sz(s)-j;i++){
    		str=s.substr(i, j);
    		if(st.find(str)==st.end()){
    			st.insert(str);
    		}
    		else{
    			cout<<j;
    			return 0;
    		}
    	}
    }
    cout<<0;

    return 0;
}

//#define MYDEBUG
#define _CRT_SECURE_NO_WARNINGS
//#pragma comment(linker, "/STACK:33554432")
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <functional>

#define MOD 1000000007
#define INF 200000001
#define EPS 1e-9
#define HASH_POW 257
const double PI = acos(-1.0);

using namespace std;

int main()
{
	//cin.sync_with_stdio(0);
	#ifdef MYDEBUG
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
	#else
	//freopen("journey.in", "rt", stdin);
	//freopen("journey.out", "wt", stdout);
	#endif

	string s;
	cin >> s;
	int n = s.length();
	int ans = 0;
	set <string> q;
	for (int i = 0; i < n; ++i)
	{
		for (int j = 1; j <= n - i; ++j)
		{
			string tmp = s.substr(i, j);
			if (q.find(tmp) != q.end())
				ans = max(ans, j);
			else
				q.insert(tmp);
		}
	}
	printf("%d", ans);

	#ifdef MYDEBUG
		cout << "\nTime = " << fixed << setprecision(3) << double(clock()) / CLOCKS_PER_SEC << endl;
	#endif
	return 0;
}

#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <complex>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cwchar>
#include <cwctype>
#include <exception>
#include <locale>
#include <numeric>
#include <new>
#include <stdexcept>
#include <limits>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <list>
#include <utility>
#include <bitset>
#include <algorithm>
#include <functional>
using namespace std;
set<string> ans;
int main()
{
	string s;
	cin>>s;
	for(int i=s.size()-1;i>0;i--)
	{
		ans.clear();
		for(int j=0;j+i<=s.size();j++)
		{
			ans.insert(s.substr(j,i));
		}
		if(ans.size()!=s.size()-i+1)
		{
			cout<<i;
			return 0;
		}
	}
	cout<<0;
	return 0;
}

#include <cstdio>
#include <cstring>
#include <cstdlib>

#include <iostream>
#include <algorithm>
#include <string>

#include <vector>
#include <queue>
using namespace std;

#ifdef KVARK
    #include "debug.h"
#else
    #define dbg(...) (void(1))
    #define dbgp(...) (void(1))
#endif
#define endl "\n"

void task() {
    string s;
    cin >> s;
    for (int len = s.length(); len; --len)
        for (int i = 0; i + len <= s.length(); ++i)
            for (int j = i + 1; j + len <= s.length(); ++j)
                if ( s.substr(i, len) == s.substr(j, len) ) {
                    cout << len << endl;
                    return;
                }
    cout << 0 << endl;
}

int main() {
#ifdef KVARK
    freopen("input.txt", "r", stdin);
    freopen("debug.txt", "w", stderr);
    //freopen("output.txt", "w", stdout);
#else
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif

    task();

#ifdef KVARK
    debug::printProcessInfo();
#endif
    return 0;
}

#include <iostream>
#include <string>
#include <map>

using namespace std;

int sz, res;
string str, s;
map <string, int> mp;
bool b;

int main ()
{
	while (getline (cin, str))
	{
		sz = str.length();
		res = 0;
		mp.clear();
		b = true;
		for (int I = sz-1; I > 0 && b; --I)
			for (int J = 0; J + I <= sz && b; ++J)
			{
				s = string (str.begin() + J, str.begin() + J + I);
				mp[s]++;
				if (mp[s] == 2)
				{
					res = I;
					b = false;
				}
			}
		cout << res << endl;
	}
	return 0;
}

#include<bits/stdc++.h>
#include<map>
#include<iostream>
#include<string>
using namespace std;
int  main(void){
	int N,i,j,k;
	string s;
	cin>>s;
	N=s.length();
	int ans=0;
	for(i=0;i<N;i++)
	for(j=0;j<N;j++)if(i<j){
		for(k=0;;k++){
			if(i+k>=N||j+k>=N||s[i+k]!=s[j+k])break;
		}
		ans=max(ans,k);
	}
	cout<<ans;
	return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <math.h>
#include <conio.h>
#include <utility>
#include <set>
#include <time.h>
#include <list>
#include <typeinfo>
#include <cstdio>
#include <numeric>
#include <limits.h>
using namespace std;

#define X first
#define Y second
#define PI 3.1415926535897932384626433832795
#define PI2 PI * 2
#define sqr(x) ((x)*(x))
typedef long long LL;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
/* sort: '>' - descending order; ascending by default. */

void load()
{
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
}

void load2()
{
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
}

void main()
{
	//load();
	string s;
	cin >> s;
	int n = s.length();
	for (int m = n - 1; m > 0; --m)
	{
		for (int i = 0; i < n - m; ++i)
		{
			string t = s.substr(i, m);
			for (int j = i + 1; j < n; ++j)
				if (s.find(t, j) != string::npos)
				{
					cout << m;
					return;
				}
		}
	}
	cout << 0;
}

/*
    Code written by Talant I.D.
*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair <int, int> pii;
typedef tuple <int, int, int> tiii;

#define precision(n) fixed << setprecision(n)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define mt make_tuple
#define mod (int)1e9+7
#define eps (double)1e-9
#define PI 2*acos(-0.0);
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define curMod 998244353

inline bool isvowel(char ch){
    ch = tolower(ch);
    return (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u');
}

bool isprime(int n){
	if(n < 2 || (n % 2 == 0 && n != 2))
		return false;
	for(int i = 3; i*i <= n; i += 2)
		if(n % i == 0) return false;
	return true;
}

int main(){
    do_not_disturb
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	string s;
	int i, j;
	set <string> st;
	map <string, int> used;
	cin >> s;
	for(i = 0; i < s.size(); i++){
		string tmp = "";
		tmp += s[i];
		st.insert(tmp);
		used[tmp]++;
		for(j = i+1; j < s.size(); j++){
			tmp += s[j];
			st.insert(tmp);
			used[tmp]++;
		}
	}
	int mx = 0;
	for(auto it : st){
		if(used[it] > 1){
			mx = max(mx, (int)it.size());
		}
	}
	cout << mx;

    return 0;
} // What is to be written here?

#include<bits/stdc++.h>
using namespace std;
int main()
{
    char a[1000];
    long long int i,j,k,l,p,q,r,s,t=0,u,v,w,x,y,z,max1=0,m;
    cin>>a;

    for(i=0;i<=strlen(a)-1;i++)
    {

        for(j=i+1;j<=strlen(a)-1;j++)
        {
            m=0;
          while(a[i+m]==a[j+m])
          {
              m++;
          }
          max1=max(m,max1);

        }
    }
    cout<<max1;

return 0;

}

#include <bits/stdc++.h>

using namespace std;

int main() {
	// your code goes here
	char input[100];
	cin>>input;
	int n = strlen(input), slen, maxSlen = 0;
	for(int i=0; i<n; i++){
	    for(int j=i+1; j<n; j++){
	        slen = 0;
	        int ix = i, jx= j;
	        while(input[ix]==input[jx]){
	            ix++;jx++;
	            slen++;
	        }
	        maxSlen = max(maxSlen,slen);
	    }
	}
	cout<<maxSlen;
	return 0;
}

#include<cstdio>
#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<math.h>
#include<string.h>
using namespace std;
int main()
{
	int i,j,m,n,q=0,k;
	char a[105];
	scanf("%s",a);
	n=strlen(a);
	for(i=0;i<n;i++)
	{
			for(k=i+1;k<n;k++)
			{
				if(a[k]==a[i])
				{
					for(j=k+1,m=i+1;j<n,m<n;j++,m++)
					{
						if(a[j]!=a[m])
						break;
					}
					q=max(j-k,q);
				}
			}
	}
	printf("%d\n",q);
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
string s,t;
int ans,kol;
int main()
{
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
        for(int j=i;j<s.size();j++)
        {
            kol=0;
            for(int k=i;k<=j;k++)
                t+=s[k];
            for(int k=0;k<=s.size()-t.size();k++)
            {
                if(s.substr(k,t.size())==t)
                    kol++;
            }
            if(kol>1)
                ans=max(ans,j-i+1);
            t.clear();
        }
    }
    cout<<ans;
}

#include <iostream>
using namespace std;
typedef long long ll;
#define Size(x) (int)(x).size()

const int N = 128;
int F[N];

int kmp(const string &p, const string &s) {
	int k = 0, ans = 0;
	for(int i = 1;i < Size(p);++i) {
		while(k > 0 && p[k] != p[i])
			k = F[k - 1];
		if(p[k] == p[i])
			++k;
		F[i] = k;
	}
	k = 0;
	for(int i = 0;i < Size(s);++i) {
		while(k > 0 && p[k] != s[i])
			k = F[k - 1];
		if(p[k] == s[i])
			++k;
		if(k == Size(p))
			++ans;
	}
	//cerr << p << " " << s << " " << ans << endl;
	return ans;
}

int main() {
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int ans = 0;
	for(int i = 0;i < Size(s);++i)
		for(int j = 0;j <= i;++j)
			if(kmp(s.substr(j, i - j + 1), s) > 1)
				ans = max(ans, i - j + 1);

	cout << ans << endl;
	return 0;
}

#include<iostream>
#include<windows.h>
#include<conio.h>
#include<time.h>
#include<string>
using namespace std;
#define rep(i,n) for((i)=0;(i)<(int)(n);(i)++)
int n,i,j,k;
string s;
int main()
{
	cin>>s;
	n=s.length();
	int ans=0;
	rep(i,n) rep(j,n) if(i<j)
	{
		for(k=0;;k++)
		if(i+k>=n || j+k>=n || s[i+k]!=s[j+k])
		break;
		ans=max(ans,k);
	}
	cout<<ans<<endl;
	return 0;
}

#include<iostream>
#include<set>
#include<string>
using namespace std;
string s;
set<string> all;
int main(){
	cin>>s;
	for(int i=s.size()-1;i>0;i--){
		all.clear();
		for(int j=0;j+i<=s.size();j++)
			all.insert(s.substr(j,i));
		if(all.size()!=s.size()-i+1){
			printf("%d\n",i);
			return 0;
		}
	}
	printf("0\n");
	return 0;
}

#include <iostream>
#include <cstring>
#include <set>
using namespace std;

int main()
{
	string s;
	cin >> s;
	int n=s.length();
	for(int length=n-1; length>=1; length--)
	{
		set <string> withLength;
		for(int start=0; start+length-1<n; start++)
		{
			string sub=s.substr(start, length);
			if(withLength.count(sub)>0)
			{
				cout << length;
				return 0;
			}
			else withLength.insert(sub);
		}
	}
	cout << 0;
	return 0;
}

#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
string s;
int ans;
int main(){
	cin>>s;
	for(int i=0;i<s.size();i++){
		for(int j=i;j<s.size();j++){
			if(s.find(s.substr(i,j-i+1),i+1)<s.size())
				ans=max(ans,j-i+1);
		}
	}
	printf("%d\n",ans);
	return 0;
}

#include <iostream>

int main() {
  std::string s;
  std::cin >> s;

  int n = s.size();
  for (int len = n - 1; len > 0; --len) {
    for (int i = 0; i + len <= n; ++i) {
      int cnt = 0;
      for (int j = 0; j < n; ++j) {
        bool flag = true;
        for (int k = 0; k < len; ++k) {
          if (s[i + k] != s[j + k]) {
            flag = false;
            break;
          }
        }
        if (flag) {
          ++cnt;
        }
      }
      if (cnt >= 2) {
        std::cout << len;
        return 0;
      }
    }
  }

  std::cout << 0;
}

#include<bits/stdc++.h>
using namespace std;
string s;
string ns;
string n;
//problem:you're given a string
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>s;
	for(int i=s.size();i>=1;i--){
		for(int j=0;j<=s.size()-i;j++){
			n=s.substr(j,i);
			ns=s;
			ns[j]='~';
			if(ns.find(n)!=-1){
				cout<<i<<endl;
				return 0;
			}
		}
	}
	int weoihfniuwegewrgiewfhweuikfhnweuifbweoifhweifhweofweiof;
	cout<<0<<endl;
	return 0;
}

#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define rep(i, n) for(int i=0; i<n; i++)
#define re return
#define fi first
#define se second
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define spr(x) ((x)*(x))

using namespace std;

typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<vi> vvi;

template<class T> T abs(T x)
{
	re x>0 ? x : -x;
}

	int n;
	int m;
	string w;
	set<string> all;
int main()
{
	cin>>w;
	int n=w.size();
	for(int i=n-1; i>0; i--)
	{
		all.clear();
		for(int j=0; j+i<=n; j++) all.insert (w.substr(j, i));
		if(all.size()!=n-i+1)
			{
				cout<<i<<endl;
				return 0;
			}
	}
	cout<<0<<endl;
	return 0;
}

#include <iostream>
#include <string>
using namespace std;

int main()
{
    string s;
    cin >> s;
    for (int i =s.size(); i>= 1; --i)
    {
        for (int j =0; j + i - 1< s.size(); ++ j)
        {
            string substring = s.substr(j,i);
            if (s.substr(j+1).find(substring) != string::npos)
            {
                cout << i;
                return 0;
            }

        }
    }
    cout << "0";
    return 0;
}

#include <iostream>
#include <string.h>
using namespace std;
int main()
{
    int i,j,m=0,k=0;
    string str;
    cin>>str;
    for(j=0;j<str.length();j++)
    {
            i=j+1;
            while(i<str.length())
            {
                k=0;
                while(str[j+k]==str[i+k])
                    k++;
                if(k>m)
                    m=k;
                i++;
            }
    }
    cout<<m;
    return 0;
}

#include <iostream>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <stack>
#include <set>
#include <queue>
#include <sstream>
#pragma comment (linker,"/STACK:16777216")
using namespace std;
long long INF=1000*1000*1000;

int main()
{
#ifdef _DEBUG
    freopen("Input.txt","r",stdin);
    freopen("Output.txt","w",stdout);
#endif

    string s;
    cin>>s;
    for(int l=s.length();l>=1;--l)
        for(int i=0;i+l<=s.length();++i)
        {
            string t=s.substr(i,l);
            for(int j=0;j+l<=s.length();++j)
                if(j!=i && s.substr(j,l)==t)
                {
                    cout<<l;
                    return 0;
                }
        }
    cout<<0;
    return 0;
}

#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;

const int M=110;
char ptn[M+1];
int pai[M+1],m;
void kmp_preproc(char* p);

int main()
{
	cin>>ptn;
	m=strlen(ptn);
	int res=0;
	for(int j=0;j<m;j++)
	{
		kmp_preproc(ptn+j);
		for(int i=1;i<=m-j;i++)
		{
			if(res<pai[i])
				res=pai[i];
		}
	}
	cout<<res<<endl;
	return 0;
}

void kmp_preproc(char* p)
{
	pai[1]=0;
	int k=0,len=strlen(p);
	for(int q=2;q<=len;q++)
	{
		while(k>0 && p[k]!=p[q-1])
			k=pai[k];
		if(p[k]==p[q-1])
			k++;
		pai[q]=k;
	}
}

#include <iostream>
#include <string>
using namespace std;
string s;
int res=0;
int main()
{
	cin >>s;
	for (int i=0;i<s.size();i++)
	{
		for (int j=i+1;j<s.size();j++)
		{
			int k;
			for (k=0;k<=s.size()-1-j;k++) if (s[i+k]!=s[j+k]) break;
			res=max(res,k);
		}
	}
	cout <<res;
	return 0;
}

#include <iostream>
#include <algorithm>
#include <map>
using namespace std;

map <string , int> cnt;

int main()
{
	string s;
	cin >> s;
	int maax = 0;
	for(int i = 0; i < s.size() ; i++)
	{
		for(int j = 1; j  <= s.size() - i ; j++)
		{
			string t = s.substr(i , j);
			cnt[t]++;
		}
	}
	for(int i = 0; i < s.size() ; i++)
	{
		for(int j = 1; j  <= s.size() - i ; j++)
		{
			cerr << cnt[s.substr(i , j)] << " " << s.substr(i , j) << " " << i << " " << j << "\n";
			if(cnt[s.substr(i , j)] >= 2 && j > maax)
				maax = j;
		}
	}
	cout << maax;
}

#include <iostream>
using namespace std;
typedef long long ll;
#define Size(x) (int)(x).size()

const int N = 128, BASE = 727, P = 100171103;
string s;
ll hs[N], pow[N] = {1};

ll gethash(int x, int y) {
	if(!x) return hs[y];
	ll tmp = (hs[y] - hs[x - 1] * pow[y - x + 1]) % P;
	tmp = (tmp + P) % P;
	return tmp;
}

int check(int x, int y) {
	int ans = 0;
	ll tmp = gethash(x, y);
	for(int i = 0;i + (y - x) < Size(s);++i)
		if(gethash(i, i + (y - x)) == tmp)
			++ans;
	return ans;
}

int main() {
	ios::sync_with_stdio(false);
	for(int i = 1;i < N;++i)
		pow[i] = (pow[i - 1] * BASE) % P;
	cin >> s;
	ll tmp = 0;
	for(int i = 0;i < Size(s);++i) {
		tmp = (tmp * BASE + s[i]) % P;
		hs[i] = tmp;
	}
	//
	int ans = 0;
	for(int i = 0;i < Size(s);++i)
		for(int j = 0;j <= i;++j)
			if(check(j, i) > 1) {
				//cerr << j << " " << i << endl;
				ans = max(ans, i - j + 1);
			}
	cout << ans << endl;
	return 0;
}

#include <stdio.h>
#include <string.h>
#include <string>
#include <map>
using namespace std;

map <string, int> mp;

char s[101], ss[101];

int main(){
    //freopen("a.in", "r", stdin);
    scanf("%s", s);
    int len = strlen(s);
    for(int n=len-1; n>=1; n--){
        mp.clear();
        int tot = 0;
        for(int i=0; i<=len-n; i++){
            for(int j=0; j<n; j++) ss[j] = s[i+j];
            ss[n] = NULL;
            if(mp[ss]) {printf("%d\n", n); return 0;}
            mp[ss] = ++tot;
        }
    }
    puts("0");
    return 0;
}

#include <iostream>
#include <string>
using namespace std;

int main()
{
    string s;
    cin>>s;
    int sLen = s.length(), ans = 0;
    for(int i=0; i < sLen; i++)
    {
        for(int newLen=1; newLen <= sLen - i; newLen++)
        {

            string sub1 = s.substr(i, newLen);
            for(int j=i+1; j <= sLen - newLen; j++)
            {
                string sub2 = s.substr(j, newLen);
                //***********
                  // cout<<"sub1= "<<sub1<<"  sub2= "<<sub2<<endl;
                //************
                if(sub1 == sub2 && ans < newLen)
                    ans = newLen;
            }
        }
    }
    cout<<ans;
    return 0;
}

/*
 012345
"ABCDEF"

name.substr(startIndex, newSubLen)
"abcdef"
a
ab
abc
abcd
abcde
abcdef
b
bc
bcd
bcde
bcdef
c
cd
cde
cdef
d
de
def
e
ef
f

"abCCdeZZZZfghijklZZZZlmnCC"

*/

#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
#define fir first
#define sec second
#define m_p make_pair
#define y1 ygftgfgcdtfgxffgx
#define y2 yfdsesgvtyghftfvv
#define x1 xvyr6cf6fgcfgf676
#define x2 xcr6rfc5r66y6r6fr
#define up_bound upper_bound
#define low_bound lower_bound
#define next_per next_permutation
#define pb push_back
#define i_to_s to_string
typedef priority_queue<int> p_queue;
typedef priority_queue<int, vector<int>, greater<int> > min_p_queue;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int mon[20]={31,28,31,30,31,30,31,31,30,31,30,31};
ll gcd(ll x,ll y){return ((y==0)?x:gcd(y,x%y));}
int n,ans;
string s;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>s;n=s.size();s+="***";
	for(int i=0;i<n;i++)for(int j=i+1;j<n;j++){
		if(s[i]!=s[j])continue;
		int sum=0,pos1=i,pos2=j;
		while(pos2<n&&s[pos1]==s[pos2])pos1++,pos2++,sum++;
		ans=max(ans,sum);
	}
	cout<<ans;
	return 0;
}

#include <iostream>
#include <cmath>
#include <vector>
#include <set>
#include <map>
using namespace std;
#define pb push_back
const int N=500000;
int main(){
	string s;
	cin >> s;
	int ans=0;
	map <string,int> mp;
	for(int i = 0; i < s.size(); i++){
		string temp="";
		temp+=s[i];
		mp[temp]++;
		int k=temp.size();
		if(mp[temp]>1) ans=max(ans,k);
		//cout<<temp<<endl;
		for(int j = i+1; j < s.size(); j++){
		temp+=s[j];
		//cout<<temp<<endl;
		mp[temp]++;
		int k=temp.size();
		if(mp[temp]>1) ans=max(ans,k);
		}
	}
	cout<<ans<<endl;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int k,i,j,ans=0;
	for(i=0;i<s.length();++i)
	{
		for(j=0;j<s.length();++j)
		{
			if(i<j)
			{
				for(k=0;;k++)
				{
					if(i+k>=s.length()||j+k>=s.length()||s[i+k]!=s[j+k])
						break;
				}
				ans=max(ans,k);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

//Sandro Mirianashvili
#include <fstream>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <string>
#include <cassert>

#define MP make_pair
#define FOR(v,p,k) for(v=p;v<=k;++v)
#define FORD(v,p,k) for(v=p;v>=k;--v)
#define REP(i,n) for(int i=0;i<(n);++i)
#define VAR(v,i) __typeof(i) v=(i)
#define FOREACH(i,c) for(__typeof(c.begin()) i=(c.begin());i!=(c).end();++i)
#define PB push_back
#define FI first
#define SE second
#define ABS(x)(x < 0)?(-x):(x)
#define SIZE(x) (int)x.size()
#define ALL(c) (c.begin(),c.end())
#define MAX(a,b)(a > b)?(a):(b)
#define MIN(a,b)(a > b)?(b):(a)
#define ZERO(x) memset(x,0,sizeof(x))
#define PI acos(-1)
#define eps 1e-13
#define MOD 10
#define NMAX 9000
#define INF -1

using namespace std;
typedef long long ll;

string s;
int l , cnt = 0 , i , j , p = 0;

int main(){
 //freopen("input.txt","r",stdin);
 //freopen("output.txt","w",stdout);
 cin >> s;
 l = SIZE(s);
 FOR(i , 0 , l){
   FOR(j , i + 1 , l){
    p = 0;
    while(s[i + p] == s[j + p]) p++;
        cnt = max(p,cnt);
    }
 }
 cout << cnt << endl;
 return 0;
}

/*-------------------------------------------*\
 * @ mdjobayairhossain2020
 * Author : MD. JOBAYAIR HOSSAIN
 * Created: August/07/2020     14:24:58(UTC+6)
-*-------------------------------------------*/
#include <bits/stdc++.h>
using namespace std;

int main()
{   ios_base::sync_with_stdio(false);
    cin.tie(0);
                    // We just have check each possible substring in Descending-order according
    string str_01; // to the size of substrings. If we any substring which appears at least 2 times
    cin>>str_01;  // we will break all loops cause thats the Answer.
    vector<char> vec_01;
    int Break = 0, found = 0;
    for(int i=(str_01.size()-1); i>=1; i--){ // selecting the size of a possible substring in Descending-order
        for(int j=0; j<str_01.size(); j++){ // checking every substring of same size in the whole string.
            if(((j+i)-1) < str_01.size()){
                for(int x=j; x<(j+i); x++){
                    vec_01.push_back(str_01[x]); // storing a single substring to how check many it appears in the whole string
                }
                for(int p=0; p<str_01.size(); p++){ // checking how many times a substring appears in the whole string.
                    if((str_01.size() - p) >= vec_01.size()){
                        for(int q=p, id=0; q<(q+i), id<vec_01.size(); q++, id++){
                            if(vec_01[id] != str_01[q]){
                                Break++;
                                break;
                            }
                        }
                    }
                    else{
                        break;
                    }
                    if(Break == 0){
                        found++;
                        if(found == 2){ // If any substring appears at least 2 times, we will break all loops cause that's the Answer.
                            break;
                        }
                    }
                    else{
                        Break -= Break;
                    }
                }
                if(found == 2){
                    break;
                }
                else{
                    found -= found;
                    vec_01.clear();
                }
            }
        }
        if(found == 2){
            break;
        }
    }
    if(found == 2){
        cout<<vec_01.size()<<"\n";
    }
    else{
        cout<<0<<"\n";
    }

    return 0;
}

#include<iostream>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
  string s;
  cin>>s;
  int res=0;
  for (int l=1;l<=s.size();l++)
  {
    vector<string> v;
    for (int i=0;i+l-1<s.size();i++)
      v.push_back(s.substr(i,l));
    sort(v.begin(),v.end());
    for (int i=0;i<v.size()-1;i++)
      if (v[i]==v[i+1])
      {
        res=l;
        break;
      }
  }
  cout<<res<<endl;
  //system("pause");
  return 0;
}

#include<bits/stdc++.h>
using namespace std;
string k;
int pd(int l,int x,int y){
	int i,j;
	for(i=x,j=y;i<x+l,j<y+l;i++,j++)
		if(k[i]!=k[j])return 0;
	return 1;
}
int main(){
	int i,l,x,y;
	cin>>k;
	l=k.size();
	for(i=l-1;i>=1;i--)
		for(x=0;x<=l-i;x++)
			for(y=x+1;y<=l-i;y++)
				if(k[x]==k[y]&&pd(i,x,y)){
					cout<<i;
					return 0;
				}
	cout<<0;
}

#include <iostream>

using namespace std;

int main()
{
    string s;
    int ans = 0, k = 0;
    cin >> s;
    for(int i = 0; i < s.size(); i++){
        for(int j = i + 1; j < s.size(); j++){
            k = 0;
            while(s[j + k] == s[i + k]){
                k++;
                ans = max(ans, k);
            }
        }
    }
    cout << ans;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
	string s;
	cin>>s;
	int cnt = 0,ans = 0;
	int len = s.length();
	for(int i=0;i<len;i++)
	{
		for(int j=i+1;j<len;j++)
		{
			cnt = 0;
			while(s[i+cnt] == s[j+cnt])cnt++;
			ans = max(ans,cnt);
		}
	}
	cout<<ans<<endl;
	return 0;
}

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
        string s,ar[10001]={""};
        int i,j=0,max1=0;
        cin>>s;
        vector<string>v;
        for( i=0;i<s.size();i++)
        {
           for(int l=1;l<=s.size()-j;l++)
              v.push_back(s.substr(i,l));
           j++;
        }
        sort(v.begin(),v.end());
        int a[101]={0};
        for(i=v.size()-1;i>=1;i--)
          if(v[i]==v[i-1])a[v[i].size()]++;
        for(i=0;i<=100;i++)
         {//cout<<a[i]<<endl;
         if(a[i]>=1)max1=i;
         }
        cout<<max1;
        return 0;
}

#include <bits/stdc++.h>
using namespace std;
int main(){
    string str;
    cin>>str;

    int size = str.size();
    int subsize = size - 1;

    while(true){
        bool found = false;

        for(int i = 0; i < size - subsize; i++){
            string sub = str.substr(i, subsize);
            if(str.find(sub) != str.rfind(sub)){
                found = true;
                break;
            }
        }

        if(found == true || subsize == 0){
            break;
        }
        else{
            subsize--;
        }
    }
    cout<<subsize<<endl;
}

#include <iostream>
#include <string>
#include <algorithm>

int main()
{
    std::string s;
    std::cin >> s;
    int max = 0;
    typedef std::string::const_iterator sit;
    sit end = s.end();
    for(sit it1 = s.begin(); it1 != end; ++it1)
        for(sit it2 = it1 + 1; it2 != end; ++it2)
            max = std::max(max, std::mismatch(it1, it1 + (end - it2), it2).first - it1);
    std::cout << max;
}

#include<bits/stdc++.h>
using namespace std;

const int inf=0x3f3f3f3f;
const int mod=19260817;

int len;
string s;

bool check(int l)
{
	set<string> bst;
	for(int i=0;i<=len-l;++i)
	{
		string t=s.substr(i,l);
		if(bst.count(t)) return 1;
		bst.insert(t);
	}
	return 0;
}

int main()
{
//    freopen(".in","r",stdin);
//    freopen(".out","w",stdout);
	cin>>s;
	len=s.length();
	int l=0,r=len-1;
	while(l<r)
	{
		int mid=(l+r+1)/2;
		if(check(mid)) l=mid;
		else r=mid-1;
	}
	cout<<r;
//    fclose(stdin);
//    fclose(stdout);
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
int main()
{
	char a[1000];
	cin >>a;
	int len=strlen(a),Max=0;
	for (int i=0;i<len;i++)
	{
		for (int j=i+1;j<len;j++)
		{
			int t=0;
			while (a[t+i]==a[t+j])
				t++;
			Max=max(Max,t);
		}
	}
	cout <<Max;
	return 0;
}

#include<iostream>
#include<string>
using namespace std;
int main()
{
	string s;
	cin>>s;
	for(int i=s.size()-1;i>0;i--)
	{
		for(int j=0;j<=s.size()-i;j++)
		{
			for(int k=j+1;k<=s.size()-i;k++)
			{
				if(s.substr(j,i)==s.substr(k,i))
				{
					cout<<i<<"\n";
					return 0;
				}
			}
		}
	}
	cout<<"0\n";
	return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<cmath>
#include<string>
#include<vector>
#include<cctype>
#include<bitset>
#include<sstream>
#include<stdio.h>
#include<cstring>
#include<fstream>
#include<iostream>
#include<algorithm>
#include<limits.h>
#define mp make_pair
#define F first
#define S second
using namespace std;
long long int n, m,k;
int main() {
#ifndef ONLINE_JUDGE
    freopen("myfile.txt", "r", stdin);
#endif
    string s;
    cin >> s;
    int k = s.size();
    while (k--){
        for (int i = 0; i < s.size(); ++i){
            string t = s.substr(i, k+1);
            //cout << t << endl;
            int x = s.find(t, i + 1);
            if (x !=-1){
                printf("%d\n", t.size());
                return 0;
            }
        }
    }
    printf("0\n");
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
bool check(int len,string s){
    unordered_map<string,int> u;
    for(int i=0;i<s.length() - len + 1;i++){

        u[s.substr(i,len)]++;
        // for(auto i = u.begin();i != u.end();i++){
        //     cout<<i->first<<" "<<i->second<<endl;
        // }
        if(u[s.substr(i,len)] > 1)return true;
    }

    // cout<<u.size();
    return false;

}
int main(){
    string s;
    cin>>s;
    int n = s.length();
    // unordered_map<string,int> u;
    int l = 0,r = n-1;
    int len = 0;
    int ans = 0;
    while(l <= r){
        len = (l+r)/2;
        if(check(len,s)){
            l = len + 1;
            ans = max(ans,len);
        }
        else r = len - 1;

    }

    // cout<<endl;
    cout<<ans;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

int main(){
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    string s;
    cin >> s;

    int ans = 0,x = 0;
    for(int i = 0; i < s.size(); i++){
        for(int j = i + 1; j < s.size(); j++){
            x = 0;
            while(s[i + x] == s[j + x]) x++;
            ans = max(ans,x);
        }
    }
    cout << ans;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
string s;
bool kt(string t)
{
    return s.find(t) != s.rfind(t);
}
int main()
{
    cin>>s;
    int b=0;
    for(int i=0; i<s.length(); i++)
        for(int j=1; j<=s.length()-i; j++)
            if(kt(s.substr(i,j)))
                b=max(b,j);
    cout<<b<<endl;
}

#include <bits/stdc++.h>
using namespace std;
int main()
{
	string a;
	cin>>a;
	int k;
	int n=a.length(),ma=0;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(j>i)
			{
				for(k=0;;k++)
				{
					if(i+k>n || j+k>n || a[i+k]!=a[j+k])break;
				}
				ma=max(k,ma);
			}
		}
	}
	cout<<ma<<endl;
	return 0;
}

// I cant give up.

#include <bits/stdc++.h>
//#include "stdc++.h"
using namespace std;
const int N = 1e5 + 11 ;

int n; string s; map <string, int> sb;

int main(){

      cin >> s, n = s.size();
      for ( int i = 0; i < n; i++ )
          for ( int j = 1; j + i <= n; j++ ){
              string cur = s.substr(i, j);
              sb[cur]++ ;
          }

      int MAX = 0;
      for ( auto it = sb.begin(); it != sb.end(); ++it )
          if ( MAX < (*it).first.size() && (*it).second > 1 )
              MAX = (*it).first.size();

      cout << MAX;

}

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cmath>
#include<string>
#include<cstring>
#include<bitset>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<iomanip>
#include<algorithm>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
#define PI  acos(-1)
using namespace std;

const int INF = 0x3f3f3f3f;
const int maxn = 3e5+5;
int n,m,k;
string s;
void solve() {
	cin >> s;
	int len = s.length();
	int ans = 0;
	for( int k = 0 ; k < len ; ++k ) {
		for( int i = 1 ; i + k <= len ; ++i ) {
			string ss = s.substr(k, i);
			int cnt = 0;
			for( int j = 0 ; j + i <= len ; ++j ) {
				if(ss == s.substr(j , i)) cnt++;
			}
			if(cnt >= 2)
				ans = max(ans,i);
		}
	}
	cout << ans << endl;
}

main() {
	IOS;
	solve();
}

#include <iostream>
#include <bits/stdc++.h>

using namespace std;

int main()
{
   string str;
   cin >> str;

   const int len = str.size();
   map<string, int> m;

   for (int i = 0; i < len; i++)
   {
      for (int j = i; j < len; j++)
          {
             int plen = j - i + 1;
                 string s = str.substr(i, plen);
                 m[s]++;
           }
   }

   string ans;
   for (const auto &e : m)
   {
      if(e.second >= 2 && e.first.length() > ans.length()) ans = e.first;
   }

   cout << ans.size() << endl;
   return 0;
}

#include<iostream>
#include<sstream>
#include<fstream>
#include<vector>
#include<list>
#include<deque>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<cmath>
#include<ctime>
#include<iomanip>
using namespace std;
//const double eps(1e-8);
typedef long long lint;
int main(){
    string s;
    while(cin>>s){
    	int ls=s.length() ;
        int max1=0;
        for(int i=0;i < ls;i++){
                for(int j=i+1;j<ls;j++){
                    int m=0;
                    while(s[i+m]==s[j+m]){
                        m++;
                    }
                    max1=max(m,max1);
                }
            }
            cout<<max1<<endl;
    }
        return 0;
}
//23A

#include <bits/stdc++.h>
using namespace std;

int main()
{
	string s;
	cin>>s;
	int sum=0;
	for(int i=0;i<s.size();i++)
	{
		for(int j=i;j<s.size();j++)
		{
			if(s.find(s.substr(i,j-i+1),i+1)<s.size())
				sum=max(sum,j-i+1);
		}
	}
	cout<<sum;

	return 0;
}

#include<iostream>
#include<sstream>
#include<fstream>
#include<vector>
#include<list>
#include<deque>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<cmath>
#include<ctime>
#include<iomanip>
using namespace std;
typedef long long lint;
int main(){
    string s;
    while(cin>>s){
    	int ls=s.length() ;
        int max1=0;
        for(int i=0;i < ls;i++){
                for(int j=i+1;j<ls;j++){
                    int m=0;
                    while(s[i+m]==s[j+m]){
                        m++;
                    }
                    max1=max(m,max1);
                }
            }
            cout<<max1<<endl;
    }
    return  0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    map<string,int> mp;
    int n=s.size();
    for(int l=1;l<=n;l++)
    {
        for(int i=0;i<=n-l;i++)
        {
            int j=i+l-1;
            string p="";
            for(int k=i;k<=j;k++)
            {
                p+=s[k];
            }
            mp[p]++;
        }
    }
    int m=0;
    for(auto c:mp)
    {
        string a=c.first;
        int x=a.size();
        if(c.second>=2)m=max(m,x);
    }
    cout<<m;
}

#include<bits/stdc++.h>
using namespace::std;

const int N = 100 + 5;

int n;
char s[N];

int main(){
	scanf("%s", s);
	n = strlen(s);
	int ans = 0;
	for(int i = 0; i < n; i++){
		for(int j = i; j < n; j++){
			int len = j - i + 1;
			bool valid = false;
			for(int l = i + 1; l + len - 1 < n; l++){
				bool act = true;
				for(int k = 0; k < len; k++){
					if(s[i + k] != s[l + k]){
						act = false;
						break;
					}
				}
				if(act){
					valid = true;
					break;
				}
			}
			if(valid) ans = max(ans, len);
		}
	}
	printf("%d\n", ans);
	return 0;
}

/*
    In the Name Of God
*
*
*/

/// {{{ include
#include <algorithm>
#include <set>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <functional>
#include <numeric>
#include <list>
#include <queue>
#include <climits>
#include <cstring>
#include <stack>
#include <cctype>
#include <iomanip>
#include <iostream>
#include <cstdio>
#include <complex>
/// }}} include
using namespace std;

const int maxn =1<<10;
const double eps=1e-9;
const int mod=1000000009;
const int inf =0x7ffffff;
const int maxlog =20;

typedef long long ll;
typedef vector<int> vi;
typedef pair <int,int> PII;

/// {{{ define
#define all(a)  a.begin(),a.end()
#define ff   first
#define ss  second
#define sqr(x)  ((x)*(x))
#define cub(x)  ((x)*(x)*(x))
#define pb  push_back
#define mp  make_pair
#define mem(f, a) memset(f, a, sizeof(f))
#define cl  clear()
#define rall(c) (c).rbegin(), (c).rend()
//#define int long long
#define dbg(x) cerr<<((#x))<<" = "<<((x))<<" "<<endl
/// }}} define

template <class Int> inline int size (const Int &a){return (int)a.size();}

char T[maxn];
int  str[maxn]; //input
int rank[maxn],  pos[maxn]; //output
int  cnt[maxn], next[maxn]; //internal
bool  bh[maxn],  b2h[maxn];

// Compares two suffixes according to their first characters
bool smaller_first_char(int a, int b){
  return str[a] < str[b];
}

void suffixSort(int n){
  //sort suffixes according to their first characters
  for (int i=0; i<n; ++i){
    pos[i] = i;
  }
  sort(pos, pos + n, smaller_first_char);
  //{pos contains the list of suffixes sorted by their first character}

  for (int i=0; i<n; ++i){
    bh[i] = i == 0 || str[pos[i]] != str[pos[i-1]];
    b2h[i] = false;
  }

  for (int h = 1; h < n; h <<= 1){
    //{bh[i] == false if the first h characters of pos[i-1] == the first h characters of pos[i]}
    int buckets = 0;
    for (int i=0, j; i < n; i = j){
      j = i + 1;
      while (j < n && !bh[j]) j++;
      next[i] = j;
      buckets++;
    }
    if (buckets == n) break; // We are done! Lucky bastards!
    //{suffixes are separted in buckets containing strings starting with the same h characters}

    for (int i = 0; i < n; i = next[i]){
      cnt[i] = 0;
      for (int j = i; j < next[i]; ++j){
        rank[pos[j]] = i;
      }
    }

    cnt[rank[n - h]]++;
    b2h[rank[n - h]] = true;
    for (int i = 0; i < n; i = next[i]){
      for (int j = i; j < next[i]; ++j){
        int s = pos[j] - h;
        if (s >= 0){
          int head = rank[s];
          rank[s] = head + cnt[head]++;
          b2h[rank[s]] = true;
        }
      }
      for (int j = i; j < next[i]; ++j){
        int s = pos[j] - h;
        if (s >= 0 && b2h[rank[s]]){
          for (int k = rank[s]+1; !bh[k] && b2h[k]; k++) b2h[k] = false;
        }
      }
    }
    for (int i=0; i<n; ++i){
      pos[rank[i]] = i;
      bh[i] |= b2h[i];
    }
  }
  for (int i=0; i<n; ++i){
    rank[pos[i]] = i;
  }
}
// End of suffix array algorithm

int height[maxn];
// height[i] = length of the longest common prefix of suffix pos[i] and suffix pos[i-1]
// height[0] = 0
void getHeight(int n){
  for (int i=0; i<n; ++i) rank[pos[i]] = i;
  height[0] = 0;
  for (int i=0, h=0; i<n; ++i){
    if (rank[i] > 0){
      int j = pos[rank[i]-1];
      while (i + h < n && j + h < n && str[i+h] == str[j+h]) h++;
      height[rank[i]] = h;
      if (h > 0) h--;
    }
  }
}

void LRS(int n) {
   int i, maxLCP = 0;
   for(i = 1; i < n ; i++)
      if(height[i] > maxLCP)
         maxLCP = height[i];
   cout << maxLCP << endl;
}

main () {
   ios::sync_with_stdio(0);

   int n = strlen(gets(T));
   for(int i = 0 ; i < n ; i++) str[i] = T[i];
   suffixSort(n);
   getHeight(n);
   LRS(n);
}

#include <bits/stdc++.h>
using namespace std;

int main(){
    string str = "";
    cin>>str;

    int size = str.size();
    int subSize = size - 1;

    while(true){
        bool found = false;
        for(int i = 0; i < size - subSize; i++){
            string sub = str.substr(i, subSize);
            if(str.find(sub)!=str.rfind(sub)){
                found = true;
                break;
            }
        }
        if(found==true || subSize==0){
            break;
        }
        else{
            subSize--;
        }
    }
    cout<<subSize<<endl;
}

#include <iostream>
using namespace std;
#pragma GCC optimize(2)
int main()
{
	string s;
	cin>>s;
	int ans = 0;
	for(int i = 0;i < s.size(); ++i)
	{
		for(int j = 0;j < s.size(); ++j)
		{
			if(i < j)
			{
				int k = 0;
				for(;; ++k)
				{
					if(i + k >= s.size() || j + k >= s.size() || s[i + k] != s[j + k])
					{
						break;
					}
				}
				ans = max(ans,k);
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}

#include<iostream>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<string>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
map<string,int> mp;
string s;
cin>>s;
int ans=0;
for(int i=0;i<s.size();i++)
  for(int j=i;j<s.size();j++)
    mp[s.substr(i,j-i+1)]++;

for(int i=0;i<s.size();i++)
  for(int j=i;j<s.size();j++)
    if(mp[s.substr(i,j-i+1)]>=2)
      ans=max(j-i+1,ans);
cout<<ans;
return 0;}

#include <iostream>
#include <string.h>
using namespace std;
int main()
{
    int i,j,m=0,k=0;
    string str;
    cin>>str;
    for(i=0;i<str.length();i++)
    {
            j=i+1;
            while(j<str.length())
            {
                k=0;
                while(str[i+k]==str[j+k])
                    k++;
                if(k>m)
                    m=k;
                j++;
            }
    }
    cout<<m;
    return 0;
}

//#include <algorithm>
//#include <cstdio>
//#include <functional>
#include <iostream>
//#include <cfloat>
//#include <climits>
//#include <cstdlib>
//#include <cstring>
//#include <cmath>
//#include <map>
//#include <queue>
//#include <set>
//#include <sstream>
//#include <stack>
//#include <string>
//#include <time.h>
//#include <vector>
//#include <random>
//#include <unordered_set>
//#include <complex>
#define rt0 return 0
using namespace std;
int main()
{
	string s;
	int ans=0,k;
	cin>>s;
	int n=s.size();
	for(int i=0;i<s.size();i++)
		for(int j=0;j<s.size();j++)
			if(i<j)
			{
				for(k=0;;k++) if((i+k>n)or(j+k>n)or(s[i+k]!=s[j+k])) break;
				ans=max(ans,k);
			}
	cout<<ans;
    rt0;
}

// @Author : Smit Vavliya

#include <iostream>
#include <map>
#include <vector>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <climits>
#include <cstring>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <string.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
#define int long long int
#define double long double
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);
#define mod 1000000007
#define M 998244353
const int inf = 1e9;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

bool f(int x, int y)
{
    return x > y;
}

bool isPrime(int n)
{
    if (n == 1)
        return false;

    for (int i = 2; i * i <= n; i++)
    {
        if (n % i == 0)
            return false;
    }
    return true;
}

int lcm(int a, int b)
{
    return (a * b) / __gcd(a, b);
}

int gcd(int a, int b)
{
    if (b == 0)
    {
        return a;
    }
    return gcd(b, a % b);
}

string Binary(int n)
{
    string s;
    while (n)
    {
        s += to_string(n & 1);
        n = n >> 1;
    }
    return s;
}

int maxEle(vector<int> a, int n)
{
    int mx = INT_MIN;
    for (int i = 0; i < n; i++)
    {
        mx = max(mx, a[i]);
    }

    return mx;
}

int index(vector<int> a, int n, int ele)
{
    for (int i = 0; i < n; i++)
    {
        if (ele == a[i])
        {
            return i;
        }
    }

    return -1;
}

unsigned int factorial(unsigned int n)
{
    if (n == 0)
        return 1;
    return n * factorial(n - 1);
}

int power(int x, unsigned int y, int p)
{
    int res = 1;
    x = x;
    if (x == 0)
        return 0;
    while (y > 0)
    {
        if (y & 1)
        {
            res *= x;
            res %= p;
        }
        y = y >> 1;
        x = (x * x);
        x %= p;
        res %= p;
    }
    return res;
}

int modInverse(int n, int p)
{
    return power(n, p - 2, p);
}

int ncrModP(int n, int r, int p)
{
    if (r == 0)
    {
        return 1;
    }
    else if (n < r)
    {
        return 0;
    }
    else
    {
        int fac[n + 1];
        fac[0] = 1;
        for (int i = 1; i <= n; i++)
        {
            fac[i] = (fac[i - 1] * i) % p;
        }
        return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) % p;
    }
}

const int N = 1e6 + 5;
int arr[N];

signed main()
{
    FAST string s;
    cin >> s;

    vector<string> v;
    int mx = 0;
    for (int i = 0; i < s.size(); i++)
    {
        for (int j = i + 1; j < s.size() + 1; j++)
        {
            if (find(v.begin(), v.end(), s.substr(i, j)) != v.end())
                mx = max(mx, j - i);
            v.push_back(s.substr(i, j));
        }
    }

    cout << mx << endl;
}

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdio.h>
#include<utility>
#include<iomanip>
#include<stack>
#include<set>
#include<unordered_map>
#include<map>
#define ll long long

using namespace std;

int main(){
    string s;
    cin>>s;
    int n=s.size();
    int mx=0,f=0;
    for(int i=n-1;i>=0;i--){
    int in=-1;
        for(int j=i-1;j>=0;j--){
            if(s[i]==s[j]){
                in=j;
                f=1;
                break;
            }
        }
        if(in>mx) mx=in;
    }
    if(f==0) cout<<0;
    else
        cout<<mx+1;
    return 0;
}

// 2 8 3 9 4 5 5 1
// 37

#include <iostream>
using namespace std;
int main(){
    string str;
    cin>>str;
    int size = str.size();
    int subSize = size - 1;
    while(true){
        bool found = false;
        for(int i = 0; i < size; i++){
            string sub = str.substr(i, subSize);
            if(str.find(sub) != str.rfind(sub)){
                found = true;
                break;
            }
        }
        if(found == true || subSize == 0){
            break;
        }
        else{
            subSize--;
        }
    }
    cout<<subSize;
}

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<fstream>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
using namespace std;
long long int Mmax(long long int a,long long int b)
{
        if (a>b)return a;
        return b;
}
long long int Mmin(long long int a,long long int b)
{
        if (a<b)return a;
        return b;
}
long long int nod(long long int a,long long int b)
{
        while (a&&b)
        {
                if (a>b)a%=b;
                else b%=a;
        }
        return Mmax(a,b);
}
long long int nok(long long int a,long long int b)
{
        return a*b/nod(a,b);
}
bool IsPrime(long long int x)
{
        if (x<2)return false;
        long long int X=sqrt(x),i;
        for (i=2;i<=X;i++)if (x%i==0)return false;
        return true;
}
void hanoi(int n,int A,int C,int B)
{
    if (n==1)
    {
        cout<<n<<" "<<A<<" "<<C<<endl;
    }
    else
    {
        hanoi(n-1,A,B,C);
        cout<<n<<" "<<A<<" "<<C<<endl;
        hanoi(n-1,B,C,A);
    }
}
string pr2(string a,int d)
{
    if (d==0)return "0";
    string b;
    long long int sz=a.size(),i,prenos=0;
    for (i=0;i<sz;i++)
    {
        b[i]=a[i];
    }
    for (i=sz-1;i>-1;i--)
    {
        a[i]=((b[i]-'0')*d+prenos)%10+'0';
        prenos=((b[i]-'0')*d+prenos)/10;
    }
    if (prenos)a=char(prenos+'0')+a;
    return a;
}
string sum(string a,string b)
{
   bool carry=false;
   long long int i,sz1,sz2,maxsz,minsz;
   string c,d;
   sz1=a.size();
   sz2=b.size();
   maxsz=max(sz1,sz2);
   minsz=min(sz1,sz2);
   while (sz1<maxsz)
   {
       sz1++;
       a='0'+a;
   }
   while (sz2<maxsz)
   {   sz2++;
       b='0'+b;
   }
   for (i=maxsz-1;i>-1;i--)
   {
       d=char((a[i]+b[i]-96+carry)%10+48)+d;
       if (a[i]+b[i]-96+carry>9)carry=true;
       else carry=false;
   }
   if (carry==true)d=char('1')+d;
   return d;
}
string pr(string a,string b)
{
  string res="0",p,p2;
  int sz=a.size(),x=0;
  for (sz=a.size();sz>0;sz--,x++)
  {
      int d=a[sz-1]-'0';
      a=a.erase(sz-1,1);
      p2=pr2(b,d);
      p2+=p;
      res=sum(res,p2);
      p+="0";

  }
  return res;
}
bool vesokosna(long long int x)
{
        return (x%4==0&&x%100||x%400==0);
}
long long int reverse(long long int x)
{
        long long int mirror=0;
        while (x)
        {
                mirror=mirror*10+x%10;
                x/=10;
        }
        return mirror;
}
long long int ost(string x,long long int k)
{
        long long int num=0,i,sz=x.size();
        for (i=0;i<sz;i++)
        {
                num=num*10;
                num+=x[i]-'0';
                num%=k;
        }
        //cout<<num<<" "<<k<<" "<<x<<endl;
        return num;
}
int used[1048576];
int main()
{
        string a;
        cin>>a;
        int sz=a.size(),i,j,answer=0;
        for (i=0;i<sz;i++)
        {
                int cnt=0;
                for (j=i;j<sz;j++)
                {
                        cnt=cnt*1347+a[j];
                        cnt%=1048576;
                        if (!used[cnt])
                        {
                                used[cnt]=1;
                        }
                        else
                        {
                                if (j-i+1>answer)answer=j-i+1;
                        }
                }
        }
        cout<<answer<<endl;
        return 0;
}

#include <bits/stdc++.h>
using namespace std;

int main (int argc, char *argv[])
{
	string str;
	cin >> str;
	int l = 0;
	for(int i = 0; i < str.length(); ++i) {
		for(int j = i + 1; j < str.length(); ++j) {
			int len = 0;
			if(str[i] == str[j]) {
				while(str[i] == str[j] && j < str.length()) {
					len++;
					i++;
					j++;
				}
			}
			l = max(len, l);
		}
	}
	printf("%d", l);

	return 0;
}

#include <iostream>
#include <cstring>
using namespace std;
int main(){
    string s;
    int i , j , max = 0 , a[26][2] , c = 97;
    cin>>s;
    for(i = 0 ; i < 26 ; i++){
          a[i][1] = c;
          a[i][2] = 0;
          c++;
    }
    for(i = 0 ; i < s.length() ; i++)
          for(j = 0 ; j < 26 ; j++)
              if(s[i] == a[j][1]){
                  a[j][2]+=1;
                  j = 25;
              }
    for(i = 0 ; i < 26 ; i++)
        if(max < a[i][2])
           max = a[i][2];
    if(max == s.length())
    cout<<max-1;
    else if(max<2)
       cout<<"0";
       else
    cout<<max;
    return 0;
}

#include<bits/stdc++.h>

using namespace std;
int main()
{
    string st;
    cin>>st;

    map<string,int> mp;

    int res = 0;

    for(int i = 0; i < st.size() ; i++)
    {
        for(int j = i; j < st.size() ; j++)
        {
            string tmp = st.substr(i,j);

            int cnt = 0;
            for(int k = 0; k < st.size(); k++)
            {
                string sub = st.substr(k,k+(j-i));

                if( sub == tmp )
                    cnt++;
            }
            if(cnt >= 2)
            {
                res = max( res , (j-i));
            }
        }
    }

    cout<< res <<endl;

    return 0;
}

#include<cstdio>
#include<cstdlib>
#include<memory.h>
#include<algorithm>
#define LLD "%I64lld"
#define LL long long
#define _min(a,b) ((a)<(b)?(a):(b))
#define _max(a,b) ((a)>(b)?(a):(b))
#define N 111

int f,n;
char s[N];
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	gets(s+1);
	n=strlen(s+1);
	for (int i=1;i<=n;i++){
		for (int j=n-i;j;j--){
			for (int k=1;f=0,k<=n;k++) if (k+j-1<=n){
				if (k==i) continue;
				for (int l=i;l<i+j;l++) if (s[l]!=s[k+l-i]){
					f=1;
					break;
				}
				if (!f){
					printf("%d\n",j);
					return 0;
				}
			}else break;
		}
	}
	puts("0");
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

int main()
{
    string input_string;
    cin>>input_string;

    int length=input_string.size();
    bool check=false;
    for(int i=length-1;i>=0;i--)
    {
        string sub=input_string.substr(0,i);
        cout<<sub<<endl;
        for(int j=1;length>j+sub.size()-1;j++)
        {
            int n=input_string.find(sub,j);
            if(n!=-1)
            {
                check=true;
                cout<<sub.size();
                break;
            }
        }
        if(check==true)
        break;
    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    string test;
    int l,max=0;
    cin>>test;
    for(int i=0;i<test.size();i++)
    {
        for(int j=i+1;j<test.size();j++)
        {
            l=0;
            while(test[i+l]==test[j+1+l])
            {
                l++;
            }
            if(l>max)
            {
                max=l;
            }
        }
    }
    cout<<max<<endl;
    //system("pause");
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;

int conversion(string p){ int o; o=atoi(p.c_str()); return o; }
string toString(int h){ stringstream ss; ss<<h; return ss.str(); }
long long gcd(long long a,long long b) {return (b==0 ? a : gcd(b,a%b));}
long long lcm(long long a,long long b) {return (a*(b/gcd(a,b))); }
long long toi(string p){long long x;istringstream in(p); in>>x; return x;}
// IMPRMIR DECIMALES -> %.3f
// Logaritmo en cualquir base ( nota: solo cambiar el 2 ) printf("Case %d: %.0lf\n", cnt++, max(0.0,ceil(log(n) / log(2))));

int main(){

    #ifndef ONLINE_JUDGE
    freopen("D:/input.txt","r",stdin);
    //freopen("D:/output.txt","w",stdout);
    #endif

    string a,b;
    cin>>a;
    int ind=2,vec=0,no=0,res=0;
    for(int i=0;i<a.size();i++)
    {
        for(int z=2;z<=a.size();z++)
        {
            b=a.substr(i,z);
            for(int j=i;j<a.size()-1;j+=(b.size()-1))
            {
                if(a.substr(j,b.size())==b) vec++;
                else
                {
                    no++;
                    break;
                }
            }
            //cout<<b<<" "<<no<<" "<<vec<<endl;
            if(no==0&&vec>1)
                res=b.size();
            no=0,vec=0;
            ind++;
        }
    }
    cout<<res<<endl;
}

#include<iostream>
#include<conio.h>
#include<string.h>
  using namespace std;
  int main()
  {
      string s;
      short int i,j,l,max_count=-1,current_count;
      char max,current;
      getline(cin,s);
      l=s.length();
         for(i=0;i<l;i++)
            {
                 current=s[i];
                 current_count=0;
         for(j=0;j<l;j++)
                if(s[j]==current)
                      current_count++;
                if(current_count>max_count)
                   {
                       max_count=current_count;
                       max=current;
                   }
            }
       cout<<max_count;
  return 0;
}

//Sandro Mirianashvili
//#pragma comment(linker,"/STACK:256000000")
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <stack>
#include <math.h>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <iostream>
#include <set>
#include <cstring>

#define deb(x) cout << "> " << #x << " : " << (x) << endl;
#define EPS 0.000000001
#define Pi acos(-1)
#define md 1000000007
#define ins insert
#define INF 1000000500ll
#define mp make_pair
#define pb push_back
#define S size()
#define MX(aa,bb) (aa>bb?aa:bb)
#define MN(aa,bb) (aa<bb?aa:bb)
#define fi first
#define se second
#define PI pair < int,int >
#define REP(i,a,n) for(i=a;i<n;i++)
#define LL long long
#define ALL(a) (a).begin(),(a).end()

using namespace std;

string a;
LL n , cnt = 0 , answer;

int main()
{
    //freopen("f.in","r",stdin);
    //freopen("f.out","w",stdout);
    cin >> a;
    for(int i = 0 ; i < a.size() - 1 ; i++)
    {
        for(int j = i + 1 ; j < a.size() ; j++)
            while(true)
            {
                if(a[i + cnt] != a[j + cnt]) break;
                cnt++;
                answer = max(answer,cnt);
            }
            cnt = 0;
    }
    cout << answer << endl;
    return 0;
}

#include <iostream>
#include <string>
using namespace std;

int main() {
	string s;
	cin >> s;

	for(int length = (s.size()+1) / 2; length > 0; length--) {
		for(int start = 0; start < s.size() - length; start++) {
			if(s.find(s.substr(start, length), start+1) != string::npos) {
				cout << length << endl;
				return 0;
			}

		}
	}

	cout << 0 << endl;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    for(int l  = s.length(); l>0;l-- ){
        for(int i = 0; i < s.length()-l ; i ++){
            int sum=0;
            string ss = s.substr(i,l);
            for(int ii =0; ii < s.length()-l ; ii++){
                if(ss==s.substr(i,l))sum++;
                if(sum>=2){
                    cout<<(++l);
                    return 0;
                }
            }
        }
    }
    cout<<0;
    return 0;
}

#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string.h>
#include<stdlib.h>
#include<string>
#include<math.h>
#include<ctype.h>
#include<climits>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<functional>
#define stop while(1);
#define lowbit(x) (x&(-x))
#define eps (1e-8)
#define pi (acos(-1.0))
#define maxint INT_MAX
#define maxlong 0xFFFFFFFFFFFFFFFLL
using namespace std;
typedef unsigned long long u64;
#define N 110
#define forn for(i=0;i<n;i++)
#define form for(i=1;i<m;i++)
int r[N],sa[N],rank[N],height[N];
int wss[30],wa[N],wb[N],wv[N];
int cmp(int *r,int a,int b,int t)
{return r[a]==r[b]&&r[a+t]==r[b+t];}
void Da(int *r,int *sa,int n,int m){
    int i,j,p,*x=wa,*y=wb,*t;
    memset(wss,0,sizeof(wss));
    for(i=0;i<n;i++)wss[x[i]=r[i]]++;
    for(i=1;i<m;i++)wss[i]+= wss[i-1];
    for(i=n-1;i>=0;i--)sa[--wss[x[i]]]=i;
    for(j=1,p=1;p<n;j*=2,m=p){
        for(p=0,i=n-j;i<n;i++) y[p++]=i;
        for(i=0;i<n;i++)if(sa[i]>=j)y[p++]=sa[i]-j;
        for(i=0;i<n;i++)wv[i]=x[y[i]];
        memset(wss,0,sizeof(wss));
        for(i=0;i<n;i++)wss[wv[i]]++;
        for(i=1;i<m;i++)wss[i]+= wss[i-1];
        for(i=n-1;i>=0;i--)sa[--wss[wv[i]]]=y[i];
        //swap(x,y);
        for(t=x,x=y,y=t,p=1,x[sa[0]]=0,i=1;i<n;i++)
        x[sa[i]]=cmp(y,sa[i-1],sa[i],j)?p-1:p++;
    }
    return;
}
void Cal_height(int *r,int *sa,int n){
    int i,j,k=0;
    for(i=1;i<=n;i++) rank[sa[i]]=i;
    for(i=0;i<n;height[rank[i++]]=k)
    for(k?k--:0,j=sa[rank[i]-1];r[i+k]==r[j+k];k++); // == ;
}
int main()
{
    char ch[110];
    while(gets(ch))
    {
        int n=strlen(ch);
        for(int i=0;i<n;i++)r[i]=ch[i]-'a'+1;
        r[n]=0;
        Da(r,sa,n+1,28);
        Cal_height(r,sa,n);
        cout<<*max_element(height+2,height+1+n)<<endl;
    }
}
/*
abcd
ababa
zzz
*/

#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define ll unsigned long long int
#define test long int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
#define mm 1000000007

bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int binaryExponentiation(int x, int n) //function to calculate x raise to power n
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x;
		x = x * x;
		n = n / 2;
	}
	return result;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-______________________________________________________________________________

	string s;
	cin >> s;
	int cnt = 0;
	int x;
	int y;
	int n = s.length();
	string ss;
	zip(i, 0, n)
	{
		zip(j, i, n)
		{
			if (i == 0)
			{
				ss = s.substr(i, j + 1);
				y = j + 1 - i;
				x = 0;
				zip(k, 1, n)
				{
					if (ss == s.substr(k, k + y))
					{
						x++;
						if (x >= 1)
							cnt = max(cnt, y);
					}
				}
			}
			else
			{
				ss = s.substr(i, j);
				y = j + 1 - i;
				x = 0;
				zip(k, 1, n)
				{
					if (ss == s.substr(k, k + y - 1))
					{
						x++;
						if (x >= 2)
						{
							cnt = max(cnt, y);
						}
					}
				}
			}

		}
	}
	cout << cnt << en;

	return 0;
}

#ifdef ONLINE_JUDGE
#define _CRT_SECURE_NO_WARNINGS
#define _SCL_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <limits>
#include <utility>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>

using namespace std;

#define LEN(O)                  int((O).size())
#define FOR(I, M, N)            for(int I = int(M), CNT_##I = int(N); I < CNT_##I; ++I)
#define REP(I, N)               FOR(I, 0, N)
#define REV(I, N)               for(int I = int(N) - 1; I >= 0; --I)
#define EACH(T, IT, O)          for(T::iterator IT = (O).begin(); IT != (O).end(); ++IT)
#define ELEM(XS)                (XS).begin(), (XS).end()
#define MP                      make_pair

template <typename S, typename T> void fill_(S& buf, const T& x){fill_n(reinterpret_cast<T*>(&buf), sizeof(buf) / sizeof(T), x);}
template <typename T, int N> inline int countof(const T(&)[N]){return N;}
template <typename T> inline vector<T>& operator +=(vector<T>& ret, const T& x){ret.push_back(x);return ret;}
#endif
#include "stdio.h" // Pre-compiled header file.

typedef set<int> SI;

int N;

int main(int argc, char* argv[])
{
#ifndef ONLINE_JUDGE
freopen("sample.txt", "r", stdin);{
#endif
    SI si;
    cin >> N;
    int x;
    REP(i, N){
        cin >> x;
        si.insert(x);
    }
    if(LEN(si) < 2)
        cout << "NO" << endl;
    else
        cout << *++si.begin() << endl;

    return 0;
#ifndef ONLINE_JUDGE
}
#endif
}

#include<iostream>
#include<string>
using namespace std;
int main(){
	string s1,s2;
	int i,j;
	int count;
	int pos1,pos2;
	int tar;
	while(cin>>s1){
		count=tar=0;
		for(i=0;i<s1.size();i++)
		for(j=1;j<=s1.size()-i;j++){
			s2=s1.substr(i,j);
			pos1=s1.find(s2);
			pos2=s1.find(s2,pos1+1);
			if(pos1!=-1&&pos2!=-1&&j-i>tar)	tar=j;
			//cout<<s2<<" "<<pos1<<" "<<pos2<<" "<<tar<<endl;
		}
		cout<<tar<<endl;
	}
	return 0;
}

#include <iostream>
#include <fstream>
#include <sstream>

#include <vector>
#include <set>
#include <bitset>
#include <map>
#include <deque>
#include <string>

#include <algorithm>
#include <numeric>
#include <iterator>
#include <functional>

#include <cstdio>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>

#define ll long long
#define pi pair<int, int>
#define pf pair<float, int>
#define pii pair<pi, int>
#define mi map<int, int>
#define ms map<string, int>
#define mc map<char, int>
#define mpi map<pi, int>
#define F first
#define S second
#define vt vector
#define vi vector<int>
#define vd vector<double>
#define vf vector<float>
#define vl vector<long long>
#define vpi vector<pi>
#define vpf vector<pf>
#define vpii vector<pii>

#define FOR(t, q) for(int q = 0; q < t; q++)
#define RFOR(t, q) for(int q = t; q > 0; q--)
#define FORE(t, q) for(int q = 0; q <= t; q++)
#define RFORE(t, q) for(int q = t; q >= 0; q--)

#define FORN(t, q, v) for(int q = v; q < t; q++)
#define RFORN(t, q, v) for(int q = t; q > v; q--)
#define FOREN(t, q, v) for(int q = v; q <= t; q++)
#define RFOREN(t, q, v) for(int q = t; q >= v; q--)

#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()

#define B(v) v.begin()
#define RB(v) v.rbegin()
#define E(v) v.end()
#define RE(v) v.rend()

#define TC int t; cin >> t; FOR(t, q)

using namespace std;

int main() {
    string s;
    cin >> s;
    int n = s.length();
    int m = 0;
    for(int i = 0; i < n; i++) {
        for(int c = i+1; c < n; c++) {
            string str = s.substr(i, c);
            string left = s.substr(i+1);
            int len = str.length();
            int v = left.find(str);
            // cout<<str<<"\t"<<left<<'\t'<<v<<'\n';
            if(v != -1) {
                m = max(m, len);
            }
        }
    }
    cout<<m;
    return 0;
}

#include<iostream>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
int ans;
int main()
{
  string s;
  cin>>s;
  int N=s.size();
  for (int i=0;i<N;i++)
    for (int j=i+1;j<N;j++)
      for (int k=0;;k++)
      {
        if (j+k>=N||s[i+k]!=s[j+k])
          break;
        ans=max(ans,k);
      }
  cout<<ans<<endl;
  //system("pause");
  return 0;
}

#include <cstdlib>
#include <iostream>
#include <stack>
#include <cstring>
#include <cmath>
#include <string>
#include <stdio.h>
#include <map>
#include <queue>
#include <list>
#include <vector>
#include <algorithm>

#define EPS 1e-8
#define FOR(i,a,n) for(int i=a;i<n;i++)
#define FORN(i,a,n) for(int i=a;i<=n;i++)
#define ALL(v) v.begin(),v.end()

const int MAX=1000;

typedef __int64 LONG;

using namespace std;

vector<int> prefix_function(string s)
{
    int len = s.length();
    vector<int> p(len);
    p[0] = 0;
    int k = 0;
    for(int i = 1; i < len; i++)
    {
        while ( (k > 0) && (s[k] != s[i]) ) k = p[k-1];
        if (s[k] == s[i]) k++;
        p[i] = k;
    }
    return p;
}

vector<int> KMP(string text, string str)
{
    vector <int> out;
    vector<int> pref = prefix_function(str);
    int i=0,j=0;
    while ( i < text.length() )
    {
        while ( j > 0 && str[ j ] != text[ i ] ) j = pref[ j - 1];
        if(str[j]==text[i]) j++;
        if ( j >= str.length() ) out.push_back( i - j + 1 );
        i++;
   }
   return out;
}

int main(int argc, char *argv[])
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    string s;
    int maxLen = 0;
    cin >> s;
    FOR(i, 0 , s.length())
    {
        FOR(j, i + 1, s.length() + 1)
        {
            string tmp = s.substr(i, j);
            vector <int> vOut = KMP(s, tmp);
            if(vOut.size() > 1 && tmp.size() > maxLen) maxLen = tmp.size();
        }
    }
    cout << maxLen;
    return EXIT_SUCCESS;
}

#include <bits/stdc++.h>
using namespace std;
#define fr first
#define sc second
#define pb push_back
#define mk make_pair
#define OK puts("OK");
#define sz(s) (int)s.size()
#define pii pair<int,int>
#define int long long
#define all(s) s.begin(), s.end()
#define rep(i,n) for (i=0;i<(n);++i)
#define rep1(i,n) for (i=1;i<=(n);++i)
#define ret return
#define nemeshay ios::sync_with_stdio(0),cin.tie(0);
const int N=1e6+12,INF=1e9+7;
int q[200][200];
bool counter(string a,string b){
    int c=0,i,j;
    for (i=0;i<a.size()-b.size()+1;++i){
        if (a[i]==b[0]){
            for (j=0;j<b.size();++j)
                if (a[i+j]!=b[j])break;
            if (b.size()==j && c==1)ret 1;
            if (b.size()==j)c = 1;
        }
    }
    ret 0;
}
main(){
    nemeshay
    string s;
    cin>>s;
    int i,j,ans=0;
    for (i=0;i<s.size();++i){
        for (j=2;j<s.size()-i+1;++j){
            string c=s.substr(i,j);
            if (counter(s,c)){
                ans=max(ans,c.size()*1ll);
            }
        }
    }
    cout <<ans;

}

#define _CRT_SECURE_NO_WARNINGS
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<cmath>
#include<string>
#include<vector>
#include<cctype>
#include<bitset>
#include<sstream>
#include<stdio.h>
#include<cstring>
#include<fstream>
#include<iostream>
#include<algorithm>
#include<limits.h>
#define mp make_pair
#define F first
#define S second
using namespace std;
int n, m;
int main() {
#ifndef ONLINE_JUDGE
    //freopen("myfile.txt", "r", stdin);
#endif
    string s, t;
    cin >> s;
    int i = 0;
    int k = s.size();
    while (1){
        if (k == 0){
            i++;
            k = s.size();
        }
        t = s.substr(i, k);
        int x = s.find(t);
        int y = s.find(t, x + 1);
        if (y != -1){
            printf("%d\n", t.size());
            return 0;
        }
        k--;
    }
    return 0;
}

#include <iostream>
#include <string>
#include <vector>

using namespace std;

int count(string p, string s){
	int result = 0;

	for (unsigned int i = 0; i <= s.length() - p.length(); i++) {
		unsigned int j;

		for (j = 0; j < p.length(); j++)
			  if (s[i+j] != p[j])
				  break;

		if (j == p.length())
			result++;

		if (result == 2)
			break;
	}

	return result;
}

int main()
{
	string s;

	cin >> s;

	vector<int> c(s.length()+1,0);

	c[0] = 2;

	for (int r = s.length()-1; r >= 0; r--)
		for (int l = 0; l <= r; l++) {
			int len = r - l + 1;

			string p = s.substr(l, r+1);

			c[len] = max(c[len], count(p,s));
		}

	for (int i = c.size() - 1; i >= 0; i--)
		if (c[i] >= 2) {
			cout << i << endl;
			break;
		}

	return 0;
}

#include<bits/stdc++.h>
using namespace std;
string s,substring;
int i,j,m;
int main()
{
     cin>>s;
     for(i=0;i<s.size();i++)
          for(j=1;j<=s.size()-1;j++)
          {
               substring=s.substr(i,j);
               if(s.find(substring,0)!=-1&&s.find(substring,0)!=i)
                    m=max(m,j);
          }
          cout<<m;
          return 0;
}

#include <cstdlib>
#include <stdio.h>
#include<string.h>
char str[101];
int main(int argc, char** argv) {
    int i,j,k,h,l,m,max=0;
    scanf("%s",str);
    l=strlen(str);
    for(i=0;i<l;i++)
        for(j=i;j<l;j++)
        {
            m=0;
            for(k=0;k<l;k++)
            {
                for(h=0;h+k<l&&h<=j-i&&h+i<l&&str[h+k]==str[h+i];h++);
                if(h==(j-i+1)) m++;
            }
            if(m>max) max=m;
        }
    if(max<2)
        max=0;
    printf("%d\n",max);
    return 0;
}

#include <iostream>
#include <string>
using namespace std;

int main()
{
	string s,b,p;
    int f[100];
	int l,i,j,t,max;
	getline(cin,s);
	l=s.length();
    for(i=1;i<=l;i++)
    {
        p[i*i]=s[i];
        for(j=l;j<=1;j--)
        {
           p[i*j]=s[j]+p[i*(j-1)];
        }
    }
    for(i=1;i<=l;i++)
        for(j=l;j<=1;j--)
        {
           max=0;
           for(t=1;t<=l;t++)
           {
                  if(p[i*j]=p[i*t])
                  {
                            b[t] =  p[i*t];
                            f[t] = b.length();
                  }
                  if(f[t]>max)
                            max=f[t];
           }
        }
    cout<<max;
    return 0;
}

#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string.h>
#include<stdlib.h>
#include<string>
#include<math.h>
#include<ctype.h>
#include<climits>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<functional>
#define stop while(1);
#define lowbit(x) (x&(-x))
#define eps (1e-8)
#define pi (acos(-1.0))
#define maxint INT_MAX
#define maxlong 0xFFFFFFFFFFFFFFFLL
using namespace std;
typedef unsigned long long u64;
#define N 110
int r[N],sa[N],rank[N],height[N];
int wss[30],wa[N],wb[N],wv[N];
int cmp(int *r,int a,int b,int t)
{return r[a]==r[b]&&r[a+t]==r[b+t];}
void Da(int *r,int *sa,int n,int m){
    int i,j,p,*x=wa,*y=wb,*t;
    memset(wss,0,sizeof(wss));
    for(i=0;i<n;i++)wss[x[i]=r[i]]++;
    for(i=1;i<m;i++)wss[i]+= wss[i-1];
    for(i=n-1;i>=0;i--)sa[--wss[x[i]]]=i;
    for(j=1,p=1;p<n;j*=2,m=p){
        for(p=0,i=n-j;i<n;i++) y[p++]=i;
        for(i=0;i<n;i++)if(sa[i]>=j)y[p++]=sa[i]-j;
        for(i=0;i<n;i++)wv[i]=x[y[i]];
        memset(wss,0,sizeof(wss));
        for(i=0;i<n;i++)wss[wv[i]]++;
        for(i=1;i<m;i++)wss[i]+= wss[i-1];
        for(i=n-1;i>=0;i--)sa[--wss[wv[i]]]=y[i];
        for(t=x,x=y,y=t,p=1,x[sa[0]]=0,i=1;i<n;i++)
        x[sa[i]]=cmp(y,sa[i-1],sa[i],j)?p-1:p++;
    }
    return;
}
void Cal_height(int *r,int *sa,int n){
    int i,j,k=0;
    for(i=1;i<=n;i++) rank[sa[i]]=i;
    for(i=0;i<n;height[rank[i++]]=k)
    for(k?k--:0,j=sa[rank[i]-1];r[i+k]==r[j+k];k++); // == ;
}
int main()
{
    char ch[110];
    while(gets(ch))
    {
        int n=strlen(ch);
        for(int i=0;i<n;i++)r[i]=ch[i]-'a'+1;
        r[n]=0;
        Da(r,sa,n+1,28);
        Cal_height(r,sa,n);
        cout<<*max_element(height+2,height+1+n)<<endl;
    }
}
/*
abcd
ababa
zzz
*/

#include <iostream>
using namespace std;

string s;

int solve() {
	//ababa
	for(int i = s.size() - 2; i >= 0; i--) {
		string sub = s.substr(0, i + 1);

		int times = 1;

		for(int j = 1; j <= s.size() - sub.size(); j++) {
			if(s.substr(j, sub.size()) == sub) times++;

			if(times == 2) return sub.size();
		}
	}

	return 0;

}

int main() {

	cin >> s;
	cout<<solve()<<endl;

	return 0;
}

#include <algorithm>
#include <map>
#include <vector>
#include <iostream>
#include <cstring>
#include <string>
using namespace std;
#define loop(_i, _n) for( _i = 0; _i < _n; _i++)
#define loopi(_i, _n, _s) for( _i = _s; _i < _n; _i++)

typedef unsigned long long ull;

ull sumbase(ull n, ull b)
{
	ull sum = 0;
	while (n) {
		sum += n % b;
		n /= b;
	}
	return sum;
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("D:\\in.txt", "r", stdin);
#endif

	int i, j, l, pos, res = 0;
	string s;
	char c;
	cin >> s;
	l = s.length();

	loop(i, l) {
		pos = s.find(s[i], i + 1);
		if (pos < 0) continue;
		j = 1;
		while (pos + j < l && s[i + j] == s[pos + j]) j++;
		res = max(j, res);
	}

	cout << res;
}

#include<stdio.h>
#include<set>
#include<queue>
#include<map>
#include<iostream>
#include<string.h>
using namespace std;
int main()
{

    map< string, int > Q;
    string G;
    char a[1000], b[1000][1000];
    int f[1000]={0};
    scanf("%s", &a);
    int l=strlen(a);
    for(int i=0;i<l;i++)
    {
        for(int q=i;q<l;q++)
        {
            b[i][q-i]=a[q];
            G=b[i];
            Q[G]++;
            if(Q[G]>1)
            {
                if(f[q-i]<Q[G]) f[q-i]=Q[G];
            }
        }
    }
    for(int i=100;i>=0;i--)
    {
        if(f[i]>1)
        {
            printf("%d", i);
            return 0;
        }
    }
    printf("0");
    return 0;
}

#include <iostream>
#include <cstring>
using namespace std;
int main(){
  int q,q1,w,e,r,t=0;
  char a[101];
  cin>>a;
  q=strlen(a);
  bool c;
  for(w=0;w<q-1;w++)
  for(e=w+1;e<q;e++){
   q1=q-e;
   c=1;
   for(r=0;r<q1;r++)
    if(a[w+r]!=a[e+r]){
     c=0;break;}
   if(c)
    if(t<q1)
     t=q1;}
  cout<<t;
  return 0;}

#include<iostream>

using namespace std;

int main()
{
    string c;
    cin >> c;
    int i, k, m = 0, j;
    int l = c.length();

    for(i = 0; i < l; i++)
    {
        for(j = i + 1; j < l; j++)
        {
            if(c[i] == c[j])
            {
                k++;
            }

        }
        m = max(m, k);
    }
    cout << m;
    return 0;
}

#include <iostream>
using namespace std;
int main(){
    string str;
    cin>>str;
    int size = str.size();
    int subSize = size - 1;
    while(true){
        bool found = false;
        for(int i = 0; i < size; i++){
            string sub = str.substr(i, subSize);
            if(str.find(sub) != str.rfind(sub)){
                found = true;
                break;
            }
        }
        if(found == true || subSize == 0){
            break;
        }
        else{
            subSize--;
        }
    }
}

#include<bits/stdc++.h>
#define w(tc) long long tc;cin>>tc;while(tc--)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
#define PI 3.14159265359
static const int INF = 1e9+7;
using namespace std;
int main()
{
    string s;
    cin>>s;
    int n=s.length();
    unordered_map<string,int>mp;
    int ma=INT_MIN;
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<n; j++)
        {
            for(int k=i; k<=j; k++)
            {
                string str;
                str=str+s[k];
                mp[str]++;
                if(mp[str]==2)
                {
                    ma=max(ma,(j-i+1));
                }
            }
        }
    }
    cout<<ma;
}

#include<iostream>
#include<string>
using namespace std;
int main()
{
	string s;
	cin >> s;
	for (int p = 0; p <= s.length() - 2; p++)
		for (int l = s.length() - 1 - p; l >= 1; l--)
			if (s.substr(p + 1, s.length() - p - 1).find(s.substr(p, l)) != -1)
			{
				cout << l;
				return 0;
			}
	cout << "0";
	return 0;
}

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

int se(char str[105],char str1[105]){
	char str2[105];int sum=0;
	memset(str2,0,sizeof(str2));
	char *p=strstr(str,str1);
	if(p){
		strcpy(str2,p+1);
		p=strstr(str2,str1);
		if(p){
			sum++;
		}
	}
	if(sum!=0) return strlen(str1);
	else return 0;
}

int main()
{
	char str[105];char str1[105];
	memset(str,0,sizeof(str));
	memset(str1,0,sizeof(str1));
	while(cin>>str){
		int dd=0;
		int d=strlen(str);
		for(int i=0;i<d;i++){
			for(int j=1;j<d;j++){
				for(int z=i,q=0;z<j;z++,q++){
					str1[q]=str[z];
				}
				int ddd=se(str,str1);
				if(dd<ddd){
					dd=ddd;
				}
			}
		}
		cout<<dd<<endl;
		memset(str,0,sizeof(str));
		memset(str1,0,sizeof(str1));
	}
	return 0;
}

//
//  main.cpp
//  turing-11
//
//  Created by 张嘉伦 on 2020/8/8.
//  Copyright © 2020 cara. All rights reserved.
//

#include <iostream>
#include<string>
using namespace std;
string a,b;
int c=0;
int main() {
    cin>>a;
    for(int i=1;i<a.size();i++){
        for(int j=1;j<=a.size()-i;j++){
            b=a.substr(j,j+i);
            if(a.find(b)!=j)c=i;
        }
    }
    cout<<c;
}

#include<iostream>
#include<conio.h>
#include<string.h>
using namespace std;
int main ()
{
    int i=0,L,a[100],j,count=0,max;
    string s;
    //cout<<"Enter your text"<<endl;
    getline(cin,s);
    L=s.length();
    while(i<100)
    {
    a[i]=0;
    i++;
    }
        for(i=0;i<L;i++)
        {
                        for(j=i+1;j<L;j++)
                        {
                        if(s[j]==s[i])
                        count++;
                        }
                        a[i]=count;
                        count=0;
        }
    max=a[0];
    for(i=0;i<L;i++)
    {
                    if(a[i]>max)
                    max=i;
    }
    if(max>0)
    cout<<max+1<<endl;
    else
    cout<<"0"<<endl;
//getch();
return 0;
}

#include<bits/stdc++.h>
using namespace std;
string t,str;
int main()
{
    int i,j,k,l,m,n,anslen=0;
    string s;
    cin>>s;
    n=s.size();
    l = n-1;
    map<string,int>mp;
    map<string,int>::iterator it;

    for(i=n; i>=0; i--)
    {
        for(j=0; j<=n-i; j++)
        {
            t = "";
            for(k=j; k<j+i; k++)
            {
                t+=s[k];

            }

            mp[t]++;
        }

    }
    for(it=mp.begin(); it!=mp.end(); it++)
    {
        if(it->second == 2)
        {
            str  = it->first;
           int  LEN = str.size();
            anslen = max(anslen,LEN);
        }
    }

    cout<<anslen<<endl;

}

#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_DEPRECATE

#pragma comment(linker, "/STACK:64000000")

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main()
{
	int n, m, v;

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

	cin >> n >> m >> v;
		v--;

	if ( (n * (n - 1) / 2) >= m)
	{
		if (m - (n - 2) > 0)
		{
			int p;
			if (v != 0) p = 0;
			else p = 1;

			cout << ++v << " " << ++p << endl;
			int k = 0;
			p--;
			v--;

			for (int i = 0; i < n - 1; ++i)
				for (int j = i + 1; j < n; ++j)
				{
					if (i != p && j != p && i != j)
					{
					cout << i + 1 << " " << j + 1 << endl;
					k++;
					if (k == m - 1) return 0;
					}
				}
			return 0;
		}
	}
	cout << "-1";

    return 0;
}

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdio.h>
#include<utility>
#include<iomanip>
#include<stack>
#include<set>
#include<unordered_map>
#include<map>
#define ll long long

using namespace std;

int main(){
    string s;
    cin>>s;
    int n=s.size();
    int mx=0,f=0;
    for(int i=n-1;i>=0;i--){
    int in=-1;
        for(int j=i-1;j>=0;j--){
            if(s[i]==s[j]){
                in=j;
                f=1;
                break;
            }
        }
        if(in>mx) mx=in;
    }
    if(f==0) cout<<0;
    else
        cout<<mx+1;
    return 0;
}

// 2 8 3 9 4 5 5 1
// 37

#include <iostream>
#include <conio.h>
using namespace std;
int t=0;
bool yeksan(string s, int a){
    for(int i=0; i<=s.size()-a ;i++){
        for(int j=i+1; j<=s.size()-a; j++){
            t=0;
            for(int k=0; k<a; k++){
                if(s[i+k]==s[j+k])
                    t++;
            }
            if(t==a)
                return true;
        }
    }
}

int main()
{
    string s;
    cin>>s;
    int a=s.size()-1;
    while(yeksan(s, a)!=true){
        a--;
    }
    cout<<a;

	return 0;
}

#include <iostream>
#include <string>
#include<conio.h>
using namespace std;

int duplicate(string source,string t){
  int f=-1,word=0;

  while(1){
      f=int( source.find(t.c_str(),f+1,t.length()));
      if(f>-1)
      word++;
      else
          break;
  }
    return word;
}

int main () {
  string s;
  getline (cin,s);
  int f=-1,leng=-1;
for(int i=0;i<s.length()-1;i++){
      for(int j=i+1;j<s.length();j++){
            int t= duplicate(s,s.substr(i,j));
            if(j-i==leng && t>f){
                    leng=j-i;
                    f=t;
            }
            if(j-i>leng && t>=2){
                    leng=j-i;
                    f=t;
            }
      }
}
if(leng==-1)
cout<<0;
else
  cout<<leng;
}

# include <iostream>
# include <string.h>
using namespace std;

void fun(string s,int start,int len,int *max);

void fun(string s,int start,int len,int *max)
{if(start<=len-2)
  {

    int i;
string t;
for(i=len-2;i>=start;i--)

   {

    t=s.substr(start,i-start+1);

    int h=start;
    while(h+i-start<len-1)
{string r;
r=s.substr(++h,i-start+1);

   if(!(r.compare(t)))
   {
       if(i+2==len)
       {
           *max=i-start+1;
           return;
       }
       else
        if((i-start+1)>*max)
            *max=i-start+1;
   }
}}
fun(s,start+1,len,max);}}
int main()
{int a;
a=0;

    string s;
    cin >> s;

fun(s,0,s.length(),&a);
    cout << a;
    return 0;}

#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;

int main()
{
    int a=0,b=0,c=0;
    string x;
    cin >> x;
    sort(x.begin(),x.end());
    for(int i=0;i<x.size()-1;i++)
    {   if(x[i]==x[i+1])a++;

    }
   cout << a;
}

#include <iostream>
#include <string>
using namespace std;

int main() {
	string s;
	cin >> s;

	for(int len = (s.size()+1) / 2; len > 0; len--) {
		for(int start = 0; start < s.size() - len; start++) {
			if(s.find(s.substr(start, start+len), start+1) != string::npos) {
				cout << len << endl;
				return 0;
			}

		}
	}

	cout << 0 << endl;
	return 0;
}

#include <iostream>
#include<string.h>
#include<algorithm>

using namespace std;

int main()
{
    char m[200];
    cin>>m;
    int l=strlen(m);
    int A[l+1][l+1];
    if(l == 1){ cout << 0;}
    else{
    for(int i = 0; i <= l;i++) A[0][i] = A[i][0] = 0;}
    int max_v=0;
    for(int i=0;i<=l;i++)
    {
        for(int j=0;j<=l;j++)
        {
            if((i!=j) && m[i-1]==m[j-1])
            {
                A[i][j]=A[i-1][j-1]+1;
            }
            else
            {
                A[i][j]=0;
            }
            max_v=max(max_v,A[i][j]);
            }
    }
    cout<<max_v;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;

string s, x;
int ans, m;
int main() {
	cin >> s;
	for (int i = 0; i < (int) s.length(); i++) {
		for (int j = i; j < (int) s.length(); j++) {
			x = "";
			m = 0;
			for (int k = i; k <= j; k++) {
				x += s[k];
			}
			for (int k = 0, t = 0; k < (int) s.length(); k++) {
				if (s[k] == x[t]) {
					t++;
				} else {
					t = 0;
				}
				if (t == (int) x.length()) {
					m++;
					t = 0;
					if (x[0] == x[x.length()-1])
						t = 1;
				}
			}
			if (m >= 2) {
				ans = max(ans, (int) x.length());
			}
		}
	}
	cout << ans;
	return 0;
}

#include <iostream>
#include <sstream>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <list>
#include <set>
#include <map>
#include <stdio.h>

using namespace std;

int main(void){
string s;
int Max=0,i,j,k,l;
//while(1){
cin>>s;
for(i=0;i<s.size();i++){
 for(l=0,j=i+1;l==0&&j<s.size();j++){
  if(s[i]==s[j]){
    l=0;
    int ii=i;
   while(j<s.size()&&s[j]==s[ii]){
    l++;
    j++;
    ii++;
                     }

    Max=max(Max,l);

                 }
                           }

                        }
cout<<Max<<"\n";
}
//}

#include<iostream>
#include<cstdio>
#include<string.h>
using namespace std;
int s,n,b;
char a[110];
bool p;
int main()
{
    gets(a);
	n=strlen(a);
	for(int l=n-1;l>=1;l--){
	  for(int i=0;i+l<=n;i++)
	    for(int j=i+1;j+i<=n;j++)
	    {
		    p=true;
		    for( b=0;b<l;b++)
		    if(a[i+b]!=a[j+b])
		    {
		    	p=false;
		    	break;
			}
			if(p)
			{
				printf("%d\n",b);
				return 0;
			}
	    }
	}
	puts("0");
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
const int maxn = 100+10;
char s[maxn];
int next1[maxn];
int main()
{
    scanf("%s",s+1);
    int len = strlen(s+1);
    int j=0;
    for(int i=2;i<=len;i++)
    {
        while(j && s[i]!=s[j+1])
        j=next1[j];
        if(s[i]==s[j+1])
        j++;
        next1[i]=j;
    }
    int maxx = 0;
    for(int i=1;i<=len;i++)
    maxx=max(maxx,next1[i]);
    printf("%d\n",maxx);
}

/*
ID: david.a3
PROG: packrec
LANG: C++
*/
#include <iostream>
#include <fstream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <stdlib.h>

#define REP(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define REPS(i,m,n) for(int (i)=(m);(i)<(int)(n);++(i))
#define FE(i, x) for(typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)

using namespace std;

int main() {
    string s,t;
    getline(cin,s);
    int j,n=s.length(),i=n,l;
    if(n==1) {
        printf("0");
        return 0;
    }
    vector<string> v;
    while(--i){
        v.push_back(s.substr(0,i));
        // t = s.substr(0,i);
        REPS(j,1,n-i+1){
            v.push_back(s.substr(j,i));
            // if (t == s.substr(j,i)) {
            //                 printf("%i",i);
            //                 return 0;
            //             }
        }
    }
    sort(v.begin(), v.end());
    n=v.size();
    s=v[--n];
    int biggest=0;
    while(--n) {
        if(s==v[n]) {
            if (s.length() > biggest) biggest = s.length();
        }
        s=v[n];
    }
    printf("%i", biggest);
    return 0;
}

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <stdlib.h>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
const ll inf = (ll)1 << 62;
const ll maxn = 2e5+10;
const int INF=0x3f3f3f3f;
char g[10][10];

int main() {
char str[110];
scanf("%s",str);
char tp[110];
int cnt=0;
for(int i=0;i<strlen(str);i++)
{tp[i]=str[i];
tp[i+1]='\0';
if(strstr(str+1,tp))  cnt=i+1;
}
cout<<cnt<<endl;
  return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long

void _init() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int main() {
	_init();

	string s;
	cin >> s;
	int ans = 0;
	for (int i = 0; i < s.length(); ++i)
	{
		for (int j = i; j < s.length(); ++j)
		{
			string temp = s.substr(i, j);
			int pos1 = i;
			int pos2 = s.find(temp);
			if (pos2 != -1 && pos1 != pos2)
			{
				ans = max(ans, (int)temp.length());
			}
		}
	}

	cout << ans << endl;
	return 0;
}

// IN THE NAME OF GOD

#include <iostream>

using namespace std;

int main()
{
    int value;
    string s;
    cin>>s;
    int n;
    n=s.size();
    int length;
    length=s.size()-1;
    bool found;
    found=false;
    while(true)
    {
        for(int i=0;i+length<n;i++)
        {
            if(s.find(s.substr(i,i+length),i+1)!=string::npos)
            {
                found=true;
                value=length;
                break;
            }
        }
        if(found==true)
        {
            break;
        }
        length--;
    }
    cout<<value;
    return 0;
}

#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count etc.
#include <cstdlib>	// require abs
#include <cstdio>	// require printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream
#include <cstring>	// require memset
#include <cctype>	// require tolower, toupper
#include <fstream>	// require freopen

using namespace std;

int main()
{
//	cut here before submit
//	freopen ("testcase.string2", "r", stdin );
	string str = "";
	cin >> str;

	int len = str.length();
	int res = 0;

	for (int i = 0; i < len; ++i ){
		for (int j = len - 1; j > i; --j ){
			string sub1 = str.substr (i, j );
//			cout << "sub1: " << sub1 << endl;
			for (int k = i + 1; k < len; ++k ){
				string sub2 = str.substr (k, j );
//				cout << "sub2: " << sub2 << endl;
				if (sub1 == sub2 ){
					res = max (res, (int)sub1.size() );
				} // end if
			} // end for
		} // end for
	} // end for

	cout << res << endl;

	return 0;
}

#include<bits/stdc++.h>
using namespace std;
const int nmax=256;
bool seen[nmax];
int main()
{

string inp;
cin>>inp;
int n=inp.size();
for(int i=n-1;i>=0;i--)
{
if(seen[inp[i]]){cout<<n-i<<endl;return 0;}
seen[inp[i]]=1;
}
cout<<0<<endl;
return 0;
}

#include <iostream>
#include <cstring>

using namespace std;

char s[101];
int lg, i, mn, j;

int main() {
    cin >> s;

    lg = strlen(s);

    for(i = 0;i < lg - 1;i++)
     for(j = i + 1;j < lg;j++) {
         if(s[i] == s[j]) {
             if(j - i > mn) mn = j - i;
             break;
         }
     }

    cout << mn << '\n';

    return 0;
}

#include <iostream>
#include <cstring>
using namespace std;
string str;
int ans;
int main()
{
	cin>>str;
	for(int i=0;i<str.size();i++)
		for(int j=i;j<str.size();j++)
		{
			string x=str.substr(i,j+1);
			//cout<<x<<endl;
			int pos=str.find(x,0);
			if(pos==string::npos) continue;
			if(str.find(x,pos+1)!=string::npos) ans=max(ans,int(x.size()));
		}
	cout<<ans;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    char a[1000];
    long long int i,j,k,l,p,q,r,s,t=0,u,v,w,x,y,z,max1=0,m;
    cin>>a;
    for(i=0;i<=strlen(a)-2;i++)
    {
        if(a[i]!=a[i+1])
        {
           t++;
        }
    }
    if(t==strlen(a)-2)
    {
        cout<<"0";
    }
    else{
    for(i=0;i<=strlen(a)-1;i++)
    {

        for(j=i+1;j<=strlen(a)-1;j++)
        {
            m=0;
          while(a[i+m]==a[j+m])
          {
              m++;
          }
          max1=max(m,max1);

        }
    }
    cout<<max1;
}

}

#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

char str[200];
int fail[200];

int main(){
    int ans=0;
    gets(str);
    for(int i=0;str[i];i++){
        for(int j=i+1;str[j];j++)
            if(str[j]==str[fail[j-1]+i])
                ans=max(ans,fail[j]=fail[j-1]+1);
        memset(fail,0,sizeof(fail));
    }
    printf("%d\n",ans);
}

// IN THE NAME OF GOD

#include <iostream>

using namespace std;

int main()
{
    int best;
    string str;
	cin>>str;
	for(int len=1;len<str.length();len++){
		for(int i=0;i+len<str.length();i++){
			if(str.find(str.substr(i,len),i+1)!=string::npos)
            {
				best=len;
				break;
            }
		}
	}
	cout<<best<<endl;
    return 0;
}

#include <bits/stdc++.h>

using namespace std;
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define ff first
#define setp setprecision(12)<<fixed
#define ss second
#define fori(v) for(int i=0; i<v; i++)
#define forj(v) for(int j=0; j<v; j++)
#define fork(v) for(int k=0; k<v; k++)
#define forl(v) for(int l=0; l<v; l++)
#define fort(v) for(int t=0; t<v; t++)
#define forz(v) for(int z=0; z<v; z++)
#define lli long long int
#define double long double
#define MAX 50100
#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define so(a) sort((a).begin(), (a).end())
#define reset(a, v) memset((a), v, sizeof(a))
int main()
{string a,b,c,d;
    cin>>a;
    int t;
    for( t=a.size();t>=1;t--) {
        vector<string>n;
        for (int i = 0; i < a.size() - t; i++) {
            b = a.substr(i, t);
            n.push_back(b); }
        int y=n.size();
        so(n);
        n.erase(unique(all(n)),n.end());
        if(y!=n.size()) {
            cout <<t<< endl;
        break;}

    }
    if(t==0)
        cout<<t<<endl;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int ans=0;
	int l=s.size();
	for(int i=l-1;i>0;i--)
	{
		vector<string> v;
		for(int j=0;j+i<l;j++)
			v.push_back(s.substr(j,i));
		sort(v.begin(),v.end());
		for(int j=1;j<v.size();j++)
			if(v[j]==v[j-1])
			{
				cout<<i+1;
				return 0;
			}
	}
	return 0;
}

#include <iostream>
using namespace std;
int main(){
    string str;
    cin>>str;
    int size = str.size();
    int subSize = size - 1;
    while(true){
        bool found = false;
        for(int i = 0; i < size; i++){
            string sub = str.substr(i, subSize);
            if(str.find(sub) != str.rfind(sub)){
                found = true;
                break;
            }
        }
        if(found == true || subSize == 0){
            break;
        }
        else{
            subSize--;
        }
    }
}

#include <bits/stdc++.h>
//in the name of god;;
using namespace std;
typedef long long ll;
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define vc vector<string>
  string s; vc v;
 int main()
 {
     cin >> s; ll total = s.size() - 1;
     for(ll i = 0; i < s.size(); ++i, --total){
     	for(ll j = 0; j <= s.size() - total; ++j){
     		v.pb(s.substr(j, total));
        }
     }
     for(ll i = 0; i < v.size(); ++i){
     	ll cnt = 1;
     	for(ll j = 0; j < v.size(); ++j){
     		if(i != j && v[i] == v[j])++cnt;
        }
        if(cnt == 2){
        	return cout << v[i].size(), 0;
		}
	 }
	 cout << "0";
 }

#include<iostream>
#include<vector>
using namespace std;

string a;
vector<string> v;

int main()
{
	string x;
	cin >> a;
	for(int i = a.size() / 2 + 1; i < (int) a.size(); i++)
	{
		for(int j = 0; j <= (int) a.size() - i + 1; j++)
		{
			x = "";
			for(int b = j; b <= (int) a.size() - i + j; b++)
				x += a[b];
			v.push_back(x);
		}
		for(int j = 0; j < (int) v.size(); j++)
			for(int b = j + 1; b < (int) v.size(); b++)
				if(v[j] == v[b])
				{
					cout << (int) v[j].size() << endl;
					return 0;
				}
	}
	cout << 0 << endl;
	return 0;
}

//
//  main.cpp
//  turing-11
//
//  Created by 张嘉伦 on 2020/8/8.
//  Copyright © 2020 cara. All rights reserved.
//

#include <iostream>
#include<string>
using namespace std;
string a,b;
int c=0;
int main() {
    cin>>a;
    for(int i=1;i<a.size()-1;i++){
        for(int j=1;j<=a.size()-i;j++){
            b=a.substr(j,j+i);
            if(a.find(b)!=j)c=i;
        }
    }
    cout<<c;
}

#include <iostream>
#include <cstring>
using namespace std;
string str;
int ans;
int main()
{
	cin>>str;
	for(int i=0;i<str.size();i++)
		for(int j=i+1;j<str.size();j++)
		{
			int l=1;
			while(j+l<str.size()&&str[i+l]==str[j+l]) l++;
			ans=max(ans,l);
		}
	cout<<ans;
	return 0;
}

#include <iostream>
#include <string.h>
using namespace std;
int main()
{
    int i , j , max = 0 ,a = 0;
    string s;
    cin>>s;
    for(i = 0 ; i < s.length() ; i++){
          for(j = i + 1 ; j < s.length() ; j++){
                a = 0;
                while(s[i+a] == s[j+a])
                    a+=1;
                if(a > max)
                    max = a;
                j+=1;
            }
    }
    cout<<max;
    return 0;
}

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string a;
	cin>>a;
	int c,s=0;
	c=a.size();
	for(int i=1;i<c-1;i++)
	{
		for(int j=0;j<c-i;j++)
		{
			for(int k=1;k<c-i;k++)
			{
				int x,y,ans;
				x=j;
				y=k;
				ans=1;
				while(x-j<=i || ans==0)
				{
					if(a[x]!=a[y])ans=0;
					x++;
					y++;
				}
				if(ans==1)s++;
			}
		}
	}
	cout<<s<<endl;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
long long n;
string s,ss,s1,s2;
void doc()
{
    cin>>s;
    n=s.length();
}
void xuly()
{
    s2=".";
    for(int i=n-1;i>=1;i--)
    {
        for(int j=0;j<=n-i;j++)
        {
            ss=s;
            s1=ss.substr(j,i);
            ss=ss.insert(j+i-1,s2);
           if (i!=1) ss=ss.erase(j,i-1);
           else ss=ss.erase(j,i);
            if (ss.find(s1)!=-1) {cout<<i;return;}
        }
    }
    cout<<0;
}
int main()
{
    doc();
    xuly();
}

#include<bits/stdc++.h>
using namespace std;
long long n;
string s,ss,s1,s2;
void doc()
{
    cin>>s;
    n=s.length();
}
void xuly()
{
    s2=".";
    for(int i=n-1;i>=1;i--)
    {
        for(int j=0;j<=n-i;j++)
        {
            ss=s;
            s1=ss.substr(j,i);
           if(i!=1) ss=ss.insert(j+i-1,s2);
           if (i!=1) ss=ss.erase(j,i-1);
           else ss=ss.erase(j,i);
            if (ss.find(s1)!=-1) {cout<<i;return;}
        }
    }
    cout<<0;
}
int main()
{
    doc();
    xuly();
}

#include <bits/stdc++.h>
#define pb push_back
#define sz(x) x.size()
#define F first
#define S second
#define mp make_pair
#define ll long long
#define sqr(x) ((x)*(x))
using namespace std;
int a[100010], b[100010], c[100010];
ll mn=1e9, mx=-1e9, ans, cnt, sm;
bool ok, okk, used[1000010], use[10];
int main(){

    //freopen ("i.txt","r",stdin);
    //freopen ("o.txt","w",stdout);

    string s;
    cin>>s;

    int z=0;
   	for(int ii=0;ii<sz(s);ii++){
   		int x=sz(s)-1;
   		for(int k=0;k<sz(s);k++){
    		string str=s.substr(z, x);
    		for(int i=0;i<=sz(s)-x;i++){
    			if(str==s.substr(i, x) && z!=i){
    				if(x!=0){
    					cout<<x;
    					return 0;
    				}
    			}
    		}
    		x--;
    	}
    	z++;
    }
    cout<<0;

    return 0;
}

#include <bits/stdc++.h>
#define fr first
#define sc scanf
#define pf printf
#define se second
#define pb push_back
#define sq(n) n * n
#define r_0 return 0
#define ll long long
#define pr pair < ll, ll >
#define prr pair < ll, pair < ll, ll > >
#define fin(s) freopen( s, "r", stdin )
#define fout(s) freopen( s, "w", stdout )
#define TIME ios_base::sync_with_stdio(0)
using namespace std;

const ll N = 1e6 + 4, MAX = 4e5 + 1, INF = 2e18, mod = 1e9 + 7;
long double PI = 3.14159265359;

string a, b;
ll mx, cnt, lnt;

main(){
    TIME;
    cin >> a;
    for( int i = 0; i < a.size(); i ++ ){
        for( int j = i; j < a.size(); j ++ ){
            b = "";
            lnt = 0;
            for( int k = i; k <= j; k ++ )b += a[k];
            for( int k = 0; k < a.size() - b.size(); k ++ ){
                cnt = 0;
                for( int h = 0; h < b.size(); h ++ )cnt += ( b[h] == a[k + h] );
                if( cnt == b.size() )lnt++;
            }
            if( lnt > 1 )
            mx = max( b.size() * 1ll, mx );
        }
    }
    cout << mx;
}

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int i,j,l,res,k,p;
string s,z[1000],c;
int main()
{

    getline(cin,s);
    res=0;
    l=s.length();
    for(i=1;i<s.length();i++)
    {
        p=0;
        for(j=0;j<l-i+1;j++)
        {
            c="";
            for(k=j;k<=j+i-1;k++)c+=s[j];
            z[p]=c;
            p++;
        }
        sort(z,z+p);
        for(j=1;j<p;j++)if(z[j]==z[j-1])res=i;
    }
    cout<<res<<endl;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	int ans=1;
	cin>>s;
	for(int i=1;i<s.size();i++)
	{
		vector<string>ss;
		for(int j=0;j<s.size()-i+1;j++)
			ss.push_back(s.substr(j,i));
		for(int j=0;j<ss.size()-1;j++)
			for(int k=j+1;k<ss.size();k++)
				if(ss[j]==ss[k])
					ans=i;
	}
	cout<<ans;
}

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#define eps 1e-10
#define inf 0x7fffffff
using namespace std;
typedef long long int64;

const int MAX = 101;
char a[MAX], b[MAX];

bool fun(int ben, int len1, int len2)
{
	int i, j=0, cnt = 0;
	for (i=ben; i<ben+len1; i++)
	{
		b[j++] = a[i];
	}
	for (i=0; i<=len2-len1; i++)
	{
		for (j=0; j<len1; j++)
		{
			if (a[i+j]!=b[j])
			{
				break;
			}
		}
		if (j == len1)
		{
			cnt++;
		}
		if (cnt>=2)
		{
			return true;
		}
	}
}

void solve()
{
	int len = strlen(a), i, j;
	for (i=len-1; i>=1; i--)
	{
		for (j=0; j<=len-i; j++)
		{
			if (fun(j, i, len))
			{
				printf("%d\n", i);
				return;
			}
		}
	}
	puts("0");
}
int main()
{
	/****************************/
	#ifndef ONLINE_JUDGE
	freopen("F:\\program study\\ACM\\1.in","r",stdin);
	freopen("F:\\program study\\ACM\\1.out","w",stdout);
	#endif
	/****************************/
	while (gets(a))
	{
		solve();
	}
	/****************************/
	#ifndef ONLIINE_JUDGE
	fclose(stdin);
	fclose(stdout);
	#endif
	/****************************/
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
string a,b="";
int maxn;
struct node{
	string a;
	int b;
};
map<string,int>m,t;
inline string read(){
	char ch=getchar();
	string st1="";
	while (!((ch>='a')&&(ch<='z'))){
		ch=getchar();
	}
	while ((ch>='a')&&(ch<='z')){
		st1+=ch,ch=getchar();
	}
	return st1;
}
int main(){
	a=read();
	for(int i=0;i<a.size();i++){
		b="";
		for(int j=i;j<a.size();j++){
			b=b+a[j];
			m[b]++;
			maxn=max(maxn,m[b]);
		}
	}
	cout<<maxn;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

map<string, int> mp;

int main() {
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++)
        for (int j = 1; i + j - 1 < s.size(); j++)
            mp[s.substr(i, j)]++;
    int ans = 0;
    for (int i = 0; i < s.size(); i++)
        for (int j = i; i + j - 1 < s.size(); j++)
            if(mp[s.substr(i, j)] > 1)
                ans = max(ans, j);
    cout << ans << endl;
    return 0;
}

#include<iostream>
#include<fstream>
#include<algorithm>
#include<vector>
#include<math.h>
#include<cmath>
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<stdio.h>
#include<queue>
#define pb push_back
#define ppb pop_back
#define nd second
#define st first
#define ll long long
#define pi 3.1415926535897932384626433832795028841971
using namespace std;
string s;
vector <string> sub;
vector <int> len;
int ans;
int main()
{
  cin>>s;
  for(int i=0;i<s.size()-1;i++)
    for(int j=1;j<s.size()-i+1;j++)
    {
      sub.pb(s.substr(i,j));
      len.pb(j);
    }
  for(int i=0;i<sub.size();i++)
    for(int j=i+1;j<sub.size();j++)
      if(sub[i]==sub[j])
        ans=max(ans,len[i]);
  cout<<ans<<endl;
  return 0;
}

 #include <iostream>
                    #include <cstdlib>
                    #include <cstdio>
                    #include <map>
                    #include <cmath>
                    #include <algorithm>
                    #include <vector>
                    #include <set>
                    #include <sstream>
                    #include <deque>
                    #define MX +100500
                    #define ll long long
                    #define uns unsigned
                    #define r0 return 0;
                    #define INF 1000000
                    #define sf scanf
                    #define pf printf
                    #define itr ::iterator
                    #define pb push_back
                    #define mp make_pair
                    #define turbo ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
                    #define all(x) x.begin(),x.end()
                    #define f first
                    #define s second
                    using namespace std;

                          string s;
                    int x,ans;
                    int main()
                    {
                        cin>>s;
                        for (int i=0;i<s.size();i++)
                        {
                            for (int j=i+1;j<s.size();j++)
                            {
                                while (s[i+x]==s[j+x]) x++;
                                ans=max(ans,x);
                            }
                            x=0;
                        }
                        cout<<ans;
                      //  system("pause");
                        r0;
                    }

// CODEFORCES ROUND @158
// Problem "A"
// codeforces.com/Na2a

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <map>

#define ll long long
#define dbg(x) cout << #x << ' ' << x << endl;

using namespace std;

string s;
int p[101];

int main() {
    cin >> s;
    for (int i = 1; i < s.length(); i++) {
        int j = p[i - 1];
        while (j > 0 && s[j] != s[i]) {
            j = p[j - 1];
        }
        if (s[j] == s[i])
            ++j;

        p[i] = j;
    }
    cout << p[s.length() - 1];
    return 0;
}

#include <iostream>
#include <cstring>

using namespace std;

int main()
{
    string text;
    bool found=false;
    cin>>text;
    for (int i=text.length()-1; i>0 && found==false; i--){
        for (int j=0; j<text.length()-i; j++){
            for (int l=j+1; l<=text.length()-i; l++){
                if (text.substr(j,i)==text.substr(l,i)){
                    cout<<i;
                    found=true;
                    break;
                }
            }
        }
    }
    if (found==false) {
        cout<<0;
    }

}

#include<bits/stdc++.h>
using namespace std;
string str;
void work(){
    int len=str.size();
    for(int qwq=len;qwq;qwq--)
    {
    	for(int qaq=1;qaq<=len-qwq+1;qaq++)
        {
            int cnt=0;
            string s=str.substr(qaq-1,qwq);
            for(int qnq=1;qnq<=len-qwq+1;qnq++) cnt+=s==str.substr(qnq-1,qwq)?1:0;
            if(cnt>=2){cout<<qwq;return;}
        }
	}
	puts("0");
}
int main()
{
    work();
    return 0;
}

// topcoder.cpp : �R���\�[�� �A�v���P�[�V�����̃G���g�� �|�C���g���`���܂��B
//

// #define LOCAL_DEBUG // ��o������

#ifdef LOCAL_DEBUG
 	#include "stdafx.h"
#endif

#include <stdio.h>
#include <string.h>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>

using namespace std;
typedef long long ll;

static const double EPS = 1e-6;
int ROUND(double x) { return (int)(x+0.5); }
bool ISINT(double x) { return fabs(ROUND(x)-x)<=EPS; }
bool ISEQUAL(double x,double y) { return fabs(x-y)<=EPS*max(1.0,max(fabs(x),fabs(y))); }
double SQSUM(double x,double y) { return x*x+y*y; }
#define PI	(3.14159265358979323846)
template<class T> bool INRANGE(T x,T a,T b) { return a<=x&&x<=b; }
#define NG (-1)
#define SZ(a) ((int)a.size())

int main(){

#ifdef LOCAL_DEBUG
	freopen("input.txt","r",stdin);
#endif
	char a[10000];
	scanf("%s ",a);
	string str(a);

	int result = -1;
	for(int k=1;k<=SZ(str);k++) // �T�C�Y
	{
		map <string, int> mp;
		for(int s=0;s<SZ(str);s++)
		{
			if(s+k<=SZ(str))
			{
				string sub = str.substr(s,k);
				mp[sub]++;
				if(mp[sub]==2)
				{
					result = max(result,k);
				}
			}
		}
	}

	printf("%d",result);

/*
#ifdef LOCAL_DEBUG
		printf("%I64d\n",ret);
#else
		printf("%I64d\n",ret);
#endif
	*/

	return 0;
}

#include <iostream>
#include <string.h>
using namespace std;
int main()
{
	int i,x,maxi=0;
	string s,ans;
	cin >> s;
	for (i=0;i<s.size();i++)
	{
		for (x=1;x<=s.size();x++)
		{
			if (s.find(s.substr(i,x))!=s.rfind(s.substr(i,x)))
			{
				if (x-i>maxi)
				maxi=x-i;
			}
		}
	}
	cout << maxi;
}

#include <iostream>
#include <conio.h>
using namespace std;
int t=0;
bool yeksan(string s, int a){
    for(int i=0; i<=s.size()-a ;i++){
        for(int j=i+1; j<=s.size()-a; j++){
            t=0;
            for(int k=0; k<a; k++){
                if(s[i+k]==s[j+k])
                    t++;
            }
            if(t==a)
                return true;
        }
    }
}

int main()
{
    string s;
    cin>>s;
    int a=s.size()-1;
    while(yeksan(s, a)!=true){
        a--;
    }
    cout<<a;

	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n=0;
	string w;
	set<string> s;
	cin>>w;
	n=w.size();
	for(int i=n-1;i>0;i--)
	{
		s.clear();
		for(int m=0;m+i<n;m++)
		s.insert(w.substr(m,i));
		if(s.size()!=n-i+1)
		{
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<0<<endl;
	return 0;

}

#include <bits/stdc++.h>

using namespace std;

map<string, int> m;

int main() {
    string s, d, ans;
    int i, j;
    cin >> s;
    for(i = 0; i < s.size(); i++) {
        d = "";
        for(j = i; j < s.size(); j++) {
            d += s[i];
            m[d]++;
            if(m[d] == 2 && d.size() > ans.size()) {
            ans = d;
            }
        }
    }
    cout << ans.size();
    return 0;
}