#include <iostream>
using namespace std;
string
str1, str2;
int
ans[1001][1001], l1, l2, maxi;
void
__init__()
{
l1 = str1.length();
l2 = str2.length();
maxi= 0;
memset( ans, 0, sizeof ans );
}
void
__dp__()
{
for( int i = 1; i <= l1; i++ )
for( int j = 1; j <= l2; j++ )
if( str1[i - 1] == str2[j - 1] )
{
ans[i][j] = ans[i - 1][j - 1] + 1;
if( maxi < ans[i][j] )
maxi = ans[i][j];
}
else
{
if( ans[i][j - 1] > ans[i - 1][j] )
ans[i][j] = ans[i][j - 1];
else
ans[i][j] = ans[i - 1][j];
}
}
void
__outp__()
{
cout << maxi << endl;
}
void
__read__()
{
while( cin >> str1 >> str2 )
{
__init__();
__dp__();
__outp__();
}
}
int
main()
{
__read__();
return 0;
}