#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;
const int N=;
int dp[N][N];
int main()
{
char s1[N],s2[N];
int l1,l2;
while(~scanf("%s%s",&s1,&s2)){
l1=strlen(s1);
l2=strlen(s2);
memset(dp,,sizeof(dp));
for(int i=;i<=l1;i++)
for(int j=;j<=l2;j++)
{
if(s1[i-]==s2[j-])dp[i][j]=dp[i-][j-]+;
else dp[i][j]=max(dp[i-][j],dp[i][j-]);
}
/* for(int i=0;i<=l1;i++)
{
for(int j=0;j<=l2;j++)
{
printf("%d ",dp[i][j]);
}
printf("\n");
}*/
printf("%d\n",dp[l1][l2]);
}
return ;
}