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

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()

		dp := make([][]int, len(S)+1)
		for i := range dp {
			dp[i] = make([]int, len(T)+1)
		}

		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>

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()-1;
    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;
}

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){
    s1="";
    s2="";
    if(!(cin >> s1 >> s2)){break;}
    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"bits/stdc++.h"
#include<iostream>
#include<ostream>
#include<vector>
#include<string>
#include<algorithm>

#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)


using namespace std;
using ll = long long;

void solve();

int main() {

   solve();
   return 0;

}

void solve() {

	string s, t;
	
	while (cin >> s >> t) {
		ll ans=0;
		vector<vector<ll>> dp;
		dp.resize(s.size()+1);
		REP(i, dp.size()) {
			dp[i].resize(t.size()+1);
			REP(j, dp[i].size()) {
				dp[i][j] = 0;
			}
		}
		REP(i, s.size()) {
			REP(j, t.size()) {
				if (s[i] == t[j]) {
					dp[i + 1][j + 1] = dp[i][j] + 1;
					//cout << "match" << endl;
				}
				else {
					ans = max(ans, dp[i][j]);
				}
			}
		}

		cout << ans << endl;

	}

}

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

int main(){
	string s,t;
while(cin>>s>>t){
	static int ans[4002][4002]={0},big=0;
	for(int i=0;i<4002;i++)for(int j=0;j<4002;j++)ans[i][j]=0;
	big=0;
	int ss=s.size(),ts=t.size();
	for(int i=ss-1;i>=0;i--){
		for(int j=ts-1;j>=0;j--){
			if(s[i]==t[j]){
				ans[i][j]=ans[i+1][j+1]+1;
				if(big<ans[i][j])big=ans[i][j];
			}
		}
	}
	cout<<big<<endl;
}
}

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

string s, t;
int dp[4005][4005], ans;

int main() {
    while(cin >> s){
        cin >> t;
        int n = s.size(), m = t.size();
        for(int i=0;i<=n;i++) fill(dp[i], dp[i]+m+1, 0);
        ans = 0;
        for(int i=0;i<n;i++){
            for(int j=0;j<m;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 <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&&!cin.eof()){
		int ans=0;
		for(int i=0; i<A.size(); ++i){
			for(int j=i+1; j<A.size(); ++j){
				string tmp="";
				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>
#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;
    int len1 = strlen(str1);
    int len2 = strlen(str2);

    for(int off = -len1; off <= len2; off++){
      int len = 0;
      for(int i = max(off, 0); i < min(len1+off, len2); i++){
        if(str1[i-off] == str2[i])
          ans = max(ans, ++len);
        else
          len = 0;
      }
    }
    print(ans);
  }
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int dp[4001][4001];
int main(void){
	string s,t;
	int i,j;
	int MAX;
	while(1){
		cin>>s>>t;
		if(cin.eof())	break;
		for(i=0;i<4001;i++){
			for(j=0;j<4001;j++){
				dp[i][j]=0;
			}
		}
		for(i=0;i<s.size();i++){
			for(j=0;j<t.size();j++){
				if(s[i]==t[j])	dp[i+1][j+1]=dp[i][j]+1;
				//else			dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1]);
			}
		}
		MAX=-1;
		for(i=0;i<=s.size();i++){
			for(j=0;j<=t.size();j++){
				MAX=max(MAX,dp[i][j]);
			}
		}
		cout<<MAX<<endl;
	}
	return 0;
}

C++: //JOI 0528 Common Sub-String
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
	while(1){
		string s, t; int roop1=0, roop2 = 0,roop3, save[650000]={}, ans = 0;
		cin>>s;
		cin>>t;
		if(cin.eof())
		break;
	for (int i = 0; i<s.size(); i++){
		for (int j = 0; j<t.size(); j++){
			if (s[i] == t[j]){
				roop1 = 0;
				save[roop2] = 0;
				while (1){
					if (s[i + roop1] == 0 || t[j + roop1] == 0){
						break;
					}
					else{
						if (s[i + roop1] == t[j + roop1]){
							save[roop2] += 1;
							roop1++;
						}
						else if (s[i + roop1] != t[j + roop1]){
							roop2++;
							break;
						}
					}
				}
			}
		}
	}
	sort(save, save + roop2 + 1);
	ans = save[roop2];
	cout << ans << endl;
	}
	return 0;
}