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>
#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=ans; i+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 <bits/stdc++.h>
using namespace std;

int dp[4444][4444];
 
int main(){

  string str1, str2;
 
  while(cin >> str1 >> str2){
   
 
    memset(dp,0,sizeof(dp));
 
    for(int i = 1; i <= str1.size(); i++){
      for(int j = 1; j <= str2.size(); j++){
        if(str1[i-1] == str2[j-1]){
          dp[i][j] = dp[i-1][j-1] + 1;
        }else dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
      }
    }
    cout << dp[str1.size()][str2.size()] << endl;
 
  }
}

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

using namespace std;

int main() {
    string s1, s2;
    while(cin >> s1 >> s2) {
        vector<vector<int> > dp(s1.size(), vector<int>(s2.size(), 0));

        int ans = 0;
        int l1 = s1.size();
        int l2 = s2.size();
        for(int i = 0; i < l1; ++i) {
            for(int j = 0; j < l2; ++j) {
                if(s1[i] == s2[j]) {
                    if(i > 0 && j > 0) dp[i][j] = dp[i-1][j-1]+1;
                    else dp[i][j] = 1;
                }
                if(dp[i][j] > ans) ans = dp[i][j];
            }
        }
        cout << ans << endl;
    }
    return 0;
}

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

using namespace std;

int check(string, string);

int main()
{
  //ifstream ifs("data.txt");
  string str1, str2;
  while( cin >> str1 >> str2 ){

    int res = 0;

    for(int i = 0; i < max(str1.size(), str2.size()); i++){
      if(str1.size() > str2.size())
	rotate(str1.begin(), str1.begin() + 1, str1.end());
      else
	rotate(str2.begin(), str2.begin() + 1, str2.end());

      res = max(res, check(str1, str2));
    }

    cout << res << endl;
  }
  //ifs.close();
}

int check(string str1, string str2)
{
  int sn = 0, res = 0;
  for(int i = 0; i < min(str1.size(), str2.size()); i++){
    if(str1[i] == str2[i]){
      sn++;
      res = max(res, sn);
    }else{
      sn = 0;
    }
  }
  return res;
}

C++: #include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
string str1;
string str2;
int main(){
	while(cin>>str1>>str2){
		int ans = 0;
		for(int i = 0;i <str1.length();i++){
			for(int j=0;j <str1.length();j++){
				string tmp =str1.substr(i,j);
				if(str2.find(tmp) !=string::npos){
					int k = tmp.length();
					ans =max(ans,k);
				}
			}
		}
		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);
        }
    }return max(ans,lon);
}
int main(){
    str s1,s2;
    LL ans=0;
    int i=0;
    while(1){
    cin >> s1 >> s2;
    if(s1=="EOF")break;
    LL l1=s1.length();
    LL l2=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>
using namespace std ;

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s,s2;
  while(cin >> s >> s2){
    ll ans = 0;
    rep(i,s.size()){
      ll len = 0;
      for(int j = 0; j < s2.size();){
        if(s[i+len] == s2[j+len]){
          len++;
          ans = max(len,ans);
          if(i+len >= s.size() || j+len >= s2.size()) break;
        }
        else{
//           if(len>1){
//             j += len-1;
//           }
//           else{
            ++j;
//           }
          len = 0;
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}