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] = 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<cstring>
#include<string>
#include<algorithm>
using namespace std;

int dp[4010][4010], maxn;
string S, T;

int main() {
	while (cin >> S >> T) {
		memset(dp, 0, sizeof(dp));
		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] = max(dp[i][j] + 1, dp[i + 1][j + 1]);
				}
			}
		}
		maxn = 0;
		for (int i = 0; i <= S.size(); i++) {
			for (int j = 0; j <= T.size(); j++) {
				maxn = max(maxn, dp[i][j]);
			}
		}
		cout << maxn << endl;
	}
}

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[i])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;
}*/