#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
using namespace std;
char str1[1000], str2[1000];
int length[1000][1000];
int main(void)
{
while (cin>>str1>>str2)
{
int len_one = strlen(str1), len_two = strlen(str2), i, j;
for (i = 0; i <= len_one; i++)
length[i][0] = 0;
for (j = 0; j <= len_two; j++)
length[0][j] = 0;
for(i=1;i<=len_one;i++)
for (j = 1; j <= len_two; j++)
{
if (str1[i - 1] == str2[j - 1])
length[i][j] = length[i - 1][j - 1] + 1;
else
length[i][j] = max(length[i - 1][j], length[i][j - 1]);
}
cout << length[len_one][len_two] << endl;
}
return 0;
}