#include<iostream>
using namespace std;
//a b s d f g s w
// a 0 0 0 0 0 0 0 0
// b 0 1 0
// d 0 0 2
// f 0 0
// g 0
// q 0
// m 0
#include<string>
#include<vector>
int GetMax(string& s1, string& s2)
{
int len1 = s1.length();
int len2 = s2.length();
vector<vector<int>> vv(len1 + 1, vector<int>(len2 + 1, 0));
int max = 0;
for (int i = 1; i <= len1; ++i)
{
for (int j = 1; j <= len2; ++j)
{
if (s1[i - 1] == s2[j - 1])
vv[i][j] = vv[i - 1][j - 1] + 1;
if (vv[i][j] > max)
max = vv[i][j];
}
}
return max;
}
int main()
{
string str1, str2;
cin >> str1 >> str2;
cout<<GetMax(str1, str2)<<endl;
return 0;
}