#include <iostream>
#include <cstring>
using namespace std;
const int MaxN=1000+50;
short int a[MaxN][MaxN];
int mymax(int, int);
int main()
{
char s1[MaxN],s2[MaxN];
int len1,len2;
cin>>(s1+1)>>(s2+1);
memset(a,0,sizeof(a));
len1=strlen(s1+1);
len2=strlen(s2+1);
for(int i=1; i<=len1; i++)
for(int j=1; j<=len2; j++)
if(s1[i]==s2[j])
a[i][j]=a[i-1][j-1]+1;
else
a[i][j]=mymax(a[i-1][j],a[i][j-1]);
cout << a[len1][len2] << endl;
return 0;
}
int mymax(int a, int b)
{
return (a>b?a:b);
}
12-29
08-16
08-16