#include<cmath> #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #define INF 30000000 #define pai 3.1415926 using namespace std; char s1[1000],s2[1000]; int dp[1000][1000]; int main() { int i,j,k; while(scanf("%s%s",s1,s2)!=EOF) { memset(dp,0,sizeof(dp)); int len1=strlen(s1); int len2=strlen(s2); for(i=1;i<=len1;i++) { for(j=1;j<=len2;j++) { dp[i][j]=max(dp[i][j-1],dp[i-1][j]); if(s1[i-1]==s2[j-1]) { dp[i][j]=max(dp[i][j],dp[i-1][j-1]+1); } } } printf("%d ",dp[len1][len2]); } return 0; }