#include <iostream> #include <cstdio> #include <cstring> using namespace std; const int maxn = 1300; char str1[maxn]; char str2[maxn]; int dp[maxn][maxn]; int Lcs() { memset(dp,0,sizeof(dp)); int length1 = strlen(str1+1); int length2 = strlen(str2+1); for(int i = 1; i <= length1; ++i) for(int j = 1; j <= length2; ++j) { if (str1[i] == str2[j]) { 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]; } } // for (int i = 0; i <= length1; ++i) // { // for (int j = 0; j <=length2 ; ++j) // { // printf("%d ",dp[i][j]); // } // printf("\n"); // } return dp[length1][length2]; } int main(int argc, char const *argv[]) { while(scanf("%s%s",str1+1,str2+1)>0) { printf("%d\n", Lcs()); } return 0; }