Go: ///
// File:  0528.go
// Author: ymiyamoto
//
// Created on Thu Mar 22 01:52:09 2018
//
package main

import (
	"bufio"
	"fmt"
	"os"
)

var S, T string
var dp [4001][4001]int

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	for {
		scanner.Scan()
		S = scanner.Text()
		if len(S) == 0 {
			return
		}

		scanner.Scan()
		T = scanner.Text()

		for i := range dp {
			for j := range dp[i] {
				dp[i][j] = 0
			}
		}

		dp[0][0] = 0
		for i := range S {
			for j := range T {
				if S[i] == T[j] {
					dp[i+1][j+1] = max(dp[i+1][j], max(dp[i][j+1], dp[i][j]+1))
				} else {
					dp[i+1][j+1] = 0
				}
			}
		}
		var m int
		for i := range dp {
			for j := range dp[i] {
				m = max(m, dp[i][j])
			}
		}
		fmt.Println(m)
	}
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x);

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

char str1[4010];
char str2[4010];

int main(){
  while(~scanf("%s %s",str1,str2)){
    int ans = 0;
    for(int i=0; str1[i]; i++){
      int tmp = 0;
      for(int j=0; str2[j]; j++){
        if(str1[i] == str2[j])
          ans = max(ans, ++tmp);
        else
          ans = 0;
      }
    }
    print(ans);
  }
  return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <utility>
#include <functional>

using namespace std;

int dp[4000][4000];

int main() {
	string s, t;

	while (cin >> s >> t) {
		fill(dp[0], dp[s.size()], 0);
		for (int i = 0; i < s.size(); ++i) {
			for (int j = 0; j < t.size(); ++j) {
				if (s[i] == t[j]) {
					if (i - 1 < 0 || j - 1 < 0) {
						dp[i][j] = 1;
					}
					else {
						dp[i][j] = dp[i - 1][j - 1] + 1;
					}
				}
			}
		}
		cout << *max_element(dp[0], dp[s.size()]) << endl;
	}

	return 0;
}

C++: #include<bits/stdc++.h>
#define LL long long
#define rep(a,b) for(int a=0;a<b;a++)
#define pb push_back
#define str string
#define INF 100000000
using namespace std;
LL sub_string(const string& s1,const string& s2,LL l1,LL l2){
    LL len=min(s1.length()-l1,s2.length()-l2);
    LL lon=0;
    LL ans=0;
    for(int j=0;j<len;j++){
        if(s1[l1+j]==s2[l2+j]){
            lon++;
        }else{
            ans=max(ans,lon);
            lon=0;
        }
    }return max(ans,lon);
}
int main(){
    str s1,s2;
    LL ans=0;
    int i=0;
    while(1){
    cin >> s1;
    if(s1=="EOF")break;
    cin >> s2;
    LL l1=s1.length();
    LL l2=0;
    ans=0;
        while(l1!=0||l2<=s2.length()){
            if(l1!=0){
                l1--;
            }else{
                l2++;
            }
            ans=max(ans,sub_string(s1,s2,l1,l2));
        }
        cout << ans << endl;
    }
return 0;
}

C++: #include<cstdio>
#include<math.h>
#include<algorithm>
#include<string.h>


using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
const int INF=1001001001;
char A[4002],B[4002];



int main(){
	while(1){
		scanf("%s",A);
		scanf("%s",B);
		int DP[4002][4002];
		int ans=0;
		rep(i,strlen(A)){
			rep(j,strlen(B)){
				if(A[i]==B[j]){
					if(i!=0&&j!=0){
						DP[i][j]+=DP[i-1][j-1];
					}
					DP[i][j]++;
				}
				ans=max(ans,DP[i][j]);
			}
		}
	printf("%d\n",ans);
	}
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

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

C++: #include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
using namespace std;

int main() {
	string s, t;
	while(cin >> s >> t){
		int n = s.size(), m = t.size(), ans = 0, c = 0;
		for(int i = 0; i < n; ++i){
			c = 0;
			for(int j = 0, k = i; j < m && k < n; ++j, ++k){
				if(s[k] == t[j]){
					c++;
				}
				else{
					ans = max(ans, c);
					c = 0;
				}
			}
            ans = max(ans, c);
		}
        
		for(int i = 0; i < m; ++i){
			c = 0;
			for(int j = 0, k = i; j < n && k < m; ++j, ++k){
				if(t[k] == s[j]){
					c++;
				}
				else{
					ans = max(ans, c);
					c = 0;
				}
			}
            ans = max(ans, c);
		}
		cout << ans << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <sstream>
#include <vector>
#include <list>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

int main() {
    string s1, s2;
    while ( cin >> s1 >> s2 ) {
        if ( s1.size() < s2.size() ) {
            swap( s1, s2 );
        }
        int lcss = 0;
        int L1 = s1.size();
        int L2 = s2.size();
        for ( int i = 0; i < L1; ++ i ) {
            int css = 0;
            for ( int j = 0; j < L2; ++ j ) {
                if ( j - i < 0 ) continue;
                if ( s1[j-i] == s2[j] ) {
                    css ++;
                    lcss = max( lcss, css );
                } else {
                    css = 0;
                }
            }
        }
        cout << lcss << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <iterator>
#include <stack>
typedef long long int lli;
using namespace std;

/*
int main(){
	int n,k;
	while(cin>>n>>k&&n!=0&&k!=0){
		vector<int> card(n+1);
		vector<int> flag(n+1);
		flag[0]=-1;
		card[0]=-1;
		for(int i=0;i<k; ++i){
			int tmp;
			cin >> tmp;
			card[tmp]=tmp;
			flag[tmp]=1;
		}
		int ans=0;
		if(flag[0]!=0){
			int cnt=0;
			int s;
			int n;
			for(int i=1;i<=n; ++i){
				if()
			}
		}
	}
	return 0;
}*/

int main(){
	string A,B;
	while(cin>>A>>B){
		int ans=0;
		for(int i=0; i<A.size(); ++i){
			for(int j=1; j<A.size(); ++j){
				string tmp=A.substr(i,j);
				/*for(int k=i;k<j; ++k){
					tmp+=A[k];
				}*/
				int a=tmp.size();
				if(B.find(tmp)!=-1) ans=max(ans,a);
			}
		}
		cout << ans << "\n";
	}
	return 0;
}

C++: #include<iostream>

using namespace std;

int solve(const string& s1, const string& s2, int sp1, int sp2){

  int tmp = 0;
  int res = 0;
  int len = min(s2.length()-sp2,s1.length()-sp1);
  
  
  for(int i = 0; i < len; i++){
    if(s1[sp1+i] != s2[sp2+i]){
      res = max(res,tmp);
      tmp = 0;
    }else{
      tmp++;
    }
  }
  return max(tmp,res);
}

int main(){
  
  string s1,s2;
  while(getline(cin,s1) && getline(cin,s2)){
    int p1 = s1.length();
    int p2 = 0;
    int ans = 0;

    while(p1!=0||p2<=(int)s2.length()){
      if(p1 != 0) p1--;
      else p2++;
      ans = max(ans,solve(s1,s2,p1,p2));
     }
    cout << ans << endl;
  }
  return 0;
}