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 <string>
#include <algorithm>
using namespace std;
const int N = 4000;
int dp[N][N];

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	string s, t;
	while(1){
		cin >> s;
		if(cin.eof() || s == "0"){ break; }
		cin >> t;
		
		for(size_t i = 0; i < s.size(); ++i){
			for(size_t j = 0; j < t.size(); ++j){
				dp[i][j] = 0;
			}
		}
		
		int ans = 0;
		for(size_t i = 0; i < s.size(); ++i){
			for(size_t 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]);
				}
				else
					dp[i + 1][j + 1] = 0;
			}
		}
		
		cout << ans << endl;
	}
	return 0;
}

C++: #include<iostream>
 
using namespace std;
 
int solve(const string& s1, const string& s2, int l1, int l2){
  int tmp = 0;
  int res = 0;
  int len = min(s2.length()-l2,s1.length()-l1);
  for(int i = 0; i < len; i++){
    if(s1[l1+i] != s2[l2+i]){
      res = max(res,tmp);
      tmp = 0;
    }else{
      tmp++;
    }
  }
  return max(tmp,res);
}
 
int main(){
   
  string s1,s2;
  int l1,l2,ans;
  while(1) {
  	cin >> s1;
  	cin >> s2;
  	l1 = s1.length();
  	l2 = 0;
  	ans = 0;
  	while(l1 != 0 || l2 <= s2.length()) {

      if(l1 != 0){
      	l1--;
      } else {
      	l2++;
      }
      ans = max(ans,solve(s1,s2,l1,l2));
  	}
    cout << ans << endl;
    
  	if(cin.eof()) {
  		break;
  	}
  }
  return 0;
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int c[4005][4005];

int lcs(string s, string s2) {
	int m = s.size();
	int n = s2.size();
	int ret = 0;

	memset(c, 0, sizeof(c));
	s = ' ' + s;
	s2 = ' ' + s2;

	REP(i,1,m+1) c[i][0] = 0;
	REP(j,1,n+1) c[0][j] = 0;

	REP(i,1,m+1) {
		REP(j,1,n+1) {
			if(s[i] == s2[j]) c[i][j] = c[i-1][j-1] + 1;
			ret = max(ret,c[i][j]);
	    }
    }

	return ret;
}

int main() {
	string a, b;
	while(cin >> a >> b) {
		cout << lcs(a, b) << endl;
	}
	return 0;
}

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

C++: #include <iostream>
#include <algorithm>
#include <string>

#define MAX 4000

using namespace std;

int dp[MAX + 2][MAX + 2];

int main(void){

  string s,t;
  while(getline(cin, s)){
    getline(cin, t);

    fill(dp[0], dp[MAX + 1] + MAX + 2, 0);

    for(int i = 0 ; i < s.size() ; i++){
      for(int 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] = 0;
      }
    }
    int ans = 0;
    for(int i = 0 ; i < s.size() ; i++){
      for(int j = 0 ; j < t.size() ; j++){
	ans = max(dp[i][j], ans);
      }
    }
    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){
		int ans=0;
		for(int i=0;i<A.size(); ++i){
			string A_dash=A.substr(i);
			vector<int> flag(A_dash.size()>B.size()?B.size():A_dash.size());
			for(int j=0; j<flag.size(); ++j){
				if(A_dash[j]==B[j])flag[j]=1;
			}
			int cnt=0;
			for(int j=0; j<flag.size();++j){
				if(flag[j]==1) {
					++cnt;
					ans=max(ans,cnt);
				}else if(flag[j]==0) cnt=0;
			}
		}
		for(int i=0;i<B.size(); ++i){
			string B_dash=B.substr(i);
			vector<int> flag(B_dash.size()>A.size()?A.size():B_dash.size());
			for(int j=0; j<flag.size(); ++j){
				if(B_dash[j]==A[j])flag[j]=1;
			}
			int cnt=0;
			for(int j=0; j<flag.size();++j){
				if(flag[j]==1) {
					++cnt;
					ans=max(ans,cnt);
				}else if(flag[j]==0) cnt=0;
			}
		}
		cout << ans << "\n";
	}
	return 0;
}


/*
int main(){
	string A;
	while(cin>>A){
		int ans=0;
		int cnt=0;
		int tmp;
		for(int j=0; j<A.size();++j){
			//cout << cnt << "\n";
			if(A[j]=='1') {
				++cnt;
				ans=max(ans,cnt);
			}else if(A[j]=='0') cnt=0;
				tmp=A[j];
		}
		cout << ans << "\n";
	}
	return 0;
}*/