/*
http://acm.hdu.edu.cn/showproblem.php?pid=1159
动态规划
dp[i][j] 表示 对于 字符串x前i 个字符 和字符串y 的前 j 个字符的最大相同子串
初始值:dp[0][0]=dp[0][1]=dp[1][0]=0
对于 i ,j 如果 x[i]==x[y] 则 dp[i][i]=dp[i-1][j-1]
如果x[i]!=y[j] 则 dp[i][j]=max{dp[i-1][j],dp[i][j-1]}
*/
#include <stdio.h>
#include <string.h>
int dp[1000][1000];
int main()
{
freopen("input.txt","r",stdin);
char x[1000],y[1000];
while(scanf("%s %s",x,y)!=EOF)
{
int lx = strlen(x);
int ly = strlen(y);
int i,j;
dp[0][0]=0;
dp[1][0]=0;
dp[0][1]=0;
for(i=1;i<=lx; i++) //要 <=
{
for(j=1; j<=ly; j++) //要 <=
{
if(x[i-1]==y[j-1])//字符串x,y的第一个字符是从 0 开始的
{
dp[i][j]=dp[i-1][j-1]+1;
}
else
dp[i][j]=dp[i-1][j]>dp[i][j-1]?dp[i-1][j]:dp[i][j-1];
}
}
printf("%d\n",dp[i-1][j-1]);
}
return 0;
}