#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int maxn=2e3;
char str1[maxn+100],str2[maxn+100];
int dp[maxn+50][maxn+50];
int main()
{
int len1,len2;
while(scanf("%s%s",str1+1,str2+1)!=EOF)
{
dp[0][0]=dp[0][1]=dp[1][0]=0;
len1=strlen(str1+1),len2=strlen(str2+1);
for(int i=1;i<=len1;i++)
for(int j=1;j<=len2;j++)
if(str1[i]==str2[j]) dp[i][j]=dp[i-1][j-1]+1;
else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
printf("%d\n",dp[len1][len2]);
}
return 0;
}