#include#include #include #include using namespace std; const int maxn = 10000; char a[maxn], b[maxn]; int d[maxn+10][maxn+10]; int dp() { int lena = strlen(a+1), lenb = strlen(b+1); int bound = max(lena, lenb)+5; for(int i = 0; i < bound; i++) { d[0][i] = 0; d[i][0] = 0; } for(int i = 1; i <= lena; i++) { for(int j = 1; j <= lenb; j++) { d[i][j] = max(d[i-1][j], d[i][j-1]); if(a[i]==b[j]) d[i][j] = max(d[i][j], d[i-1][j-1]+1); } } return d[lena][lenb]; } int main() { while(scanf("%s%s", a+1, b+1) != EOF) { int res = dp(); printf("%d\n", res); } return 0; }