#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)

int dp[2][4010];

int main(){
	string in1,in2;
	while(cin>>in1>>in2){
		int n = in1.size();
		int m = in2.size();
		int ret = 0;
		rep(i,2)rep(j,m+1)dp[i][j]=0;
		REP(i,1,n+1){
			int cur = i%2;
			int next = (i+1)%2;
			REP(j,1,m+1){
				if( in1[i-1]==in2[j-1] ){
					dp[next][j] = dp[cur][j-1] + 1;
					ret = max(ret,dp[next][j]);
				}
			}
			rep(i,m+1)dp[cur][i]=0;
		}
		printf("%d\n",ret);
	}
	return 0;
}