#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

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

int main() 
{
	while (scanf("%s %s", s, t) != EOF){
		memset(dp, 0, sizeof(dp));
		int n = strlen(s);
		int m = strlen(t);
		
		for (int i = 1; i <= n; i++){
			for (int j = 1; j <= m; j++){
				if (s[i - 1] == t[j - 1]){
					dp[i][j] = dp[i - 1][j - 1] + 1;
				}
			}
		}
		
		int maxi = 0;
		
		for (int i = 1; i <= n; i++){
			for (int j = 1; j <= m; j++){
				maxi = max(maxi, dp[i][j]);
			}
		}
		
		printf("%d\n", maxi);
	}
	
	return 0;
}