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 <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <iostream>

using namespace std;
typedef long long ll;

char in[2][4001];

void calc(){
    int l[2],p,ans=0,m;
    
    for(int i=0;i<2;i++)
        for(l[i]=0;in[i][l[i]]!='\0';l[i]++);
    
    if(l[0]<l[1])
        m=0;
    else
        m=1;
    
    for(int i=1-l[m];i<l[!m];i++){
        p=0;
        for(int j=0;j<l[m] && i+j<l[!m];j++){
            
            if(i+j<0) continue;
            
            if(in[!m][i+j]==in[m][j]){
                p++;
                ans=max(ans,p);
            }else{
                p=0;
            }
        }
    }
    
    printf("%d\n",ans);
    
    return;
}

int main(){
    string in1,in2;
    
    while(scanf("%s%s",in[0],in[1])!=EOF){
        calc();
    }
    
    return 0;
}

C++: #include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF (1<<29)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))
const int dx[] = {-1,0,0,1},dy[] = {0,1,-1,0};

typedef long long int ll;

using namespace std;

int main(){
    while(true){
	string s1,s2;
	cin >> s1;
	if(cin.eof()) break;
	cin >> s2;
	int ans = 0;
	REP(i,s1.size()){
	    char h = s1[i];
	    REP(j,s2.size()){
		if(s2[j] == h){
		    int temp = 0;
		    FOR(k,j,s2.size()){
			if(s1[i+k-j] == s2[k]) {
			    temp++;
			}else{
			    j = k-1;
			    break;
			}
		    }
		    ans = max(ans,temp);
		}
	    }
	}
	cout << ans << endl;
    }
    return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<string>
using namespace std;
int main()
{
	char a[4000],b[4000];
	while(scanf("%s",a)!=EOF){
		scanf("%s",b);
	int t[4002][4002];
	for(int i=0;i<=strlen(a);i++){
		t[0][i]=0;
	}
	for(int j=0;j<=strlen(b);j++){
		t[j][0]=0;
	}
	for(int i=1;i<=strlen(a);i++){
		for(int j=1;j<=strlen(b);j++){
			if(a[i-1]==b[j-1])t[i][j]=t[i-1][j-1]+1;
			else t[i][j]=0;
		}
	}

	int ans=0;
	for(int i=1;i<=strlen(a);i++){
		for(int j=1;j<=strlen(b);j++){
			ans=max(ans,t[i][j]);
		}
	}
	cout << ans << "\n";
	}
	return 0;
}

C++: class Main{

}

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

string s, t;
char tmp[4001];
int dp[4001][4001];

int main(){
	while(1){
		if(scanf("%s", tmp) == EOF) break;

		s = tmp;
		scanf("%s", tmp);
		t = tmp;

		for(int i=0; i<4001; i++)
			for(int j=0; j<4001; j++)
				dp[i][j] = 0;

		int ans = 0;
		for(int i=1; i<s.size(); i++){
			for(int j=1; j<t.size(); j++){
				if(s[i-1] == t[j-1]){
					dp[i][j] = dp[i-1][j-1]+1;
				}else{
					dp[i][j] = 0;
				}
				ans = max(ans, dp[i][j]);
			}
		}

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

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

int dp[4001][4001];

int main(){
	char str1[4001],str2[4001];
	while(cin>>str1>>str2){
		int ans=0;
		memset(dp,0,sizeof(dp));
		for(int i=0;str1[i]!='\0';i++){
			for(int j=0;str2[j]!='\0';j++){
				if(str1[i]==str2[j]){
					dp[i+1][j+1]=dp[i][j]+1;
				}
				if(ans<dp[i+1][j+1]){
					ans=dp[i+1][j+1];
				}
			}
		}
		printf("%d\n",ans);
	}
	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] == 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<string.h>
using namespace std;

char A[4002],B[4002];
short int length[4000][4000];
int mmax[200],mcor = 0;
int main(){
	int i,j,k,lenA,lenB;
	while(cin >> A[0]){
		cin >> A+1;
		cin >> B;
		lenA = strlen(A);
		lenB = strlen(B);
		for(i = 0;i < lenA;i++){
			for(j = 0;j < lenB;j++){
				length[i][j] = -1;
			}
		}
		//逆さからループしただけなのにオーダーが1/100になったww
		for(i = lenA-1;i >= 0;i--){
			for(j = lenB-1;j >= 0;j--){
				for(k = 0;;k++){
					if(i+k >= lenA || j+k >= lenB || A[i+k] != B[j+k]){
						length[i][j] = k;
						break;
					}
					else if(length[i+k][j+k] >= 0){
						length[i][j] = length[i+k][j+k]+k;
						break;
					}
				}
			}
		}
		for(i = 0;i < lenA;i++){
			for(j = 0;j < lenB;j++){
				if(mmax[mcor] < length[i][j])
					mmax[mcor] = length[i][j];
			}
		}
		mcor++;
	}
	for(i = 0;i < mcor;i++){
		cout << mmax[i] << endl;
	}
	return 0;
}

C++: // clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever for (;;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int n) { return n & 1; }
constexpr bool even(const int n) { return ~n & 1; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> std::istream &operator>>(std::istream &is, std::pair<A, B> &p) { is >> p.first; is >> p.second; return is; }
using namespace std;
// clang-format on

template<typename T> int ContinuousLCS(const T &a, const T &b) {
  const int n = a.size(), m = b.size();
  vvi dp(n + 1, vi(m + 1));
  int maxi = 0;
  rep(i, n) rep(j, m) {
    if (a[i] == b[j]) dp[i + 1][j + 1] = dp[i][j] + 1;
    cmax(maxi, dp[i + 1][j + 1]);
  }
  return maxi;
}

main {
  string s, t;
  while (cin >> s >> t) cout << ContinuousLCS(s, t) << endl;
}