#include<iostream>
#include<string>
using namespace std;
int dp[10005][10005];
int main()
{
string str1;
string str2;
while(cin>>str1>>str2)
{
// memset(dp,0,sizeof(dp));
int len1 = str1.length();
int len2 = str2.length();
int i,j;
for(i = 0;i <= len1;i++)
dp[i][0] = 0;
for(j = 0;j <= len2;j++)
dp[0][j] = 0;
for(i = 1;i <= len1;i++)
for(j = 1;j <= len2;j++)
{
if(str1[i-1] == str2[j-1])
dp[i][j] = dp[i-1][j -1] + 1;
else if(dp[i][j-1] > dp[i-1][j])
dp[i][j] = dp[i][j-1];
else
dp[i][j] = dp[i-1][j];
}
cout<<dp[len1][len2]<<endl;
}
return 0;
}