#include <iostream>
using namespace std;
int main() {
string x, y;
int A[2][1001];
while (cin >> x >> y )
{
for (int i = 0; i < 2; i++){
for (int j = 0; j < 1001; j++){
A[i][j] = 0;
}
}
for (int i = 0; i < x.size(); i++){
for (int j = 0; j < y.size(); j++){
if (x[i] == y[j]) A[i % 2][(j + 1)] = 1 + A[(i + 1) % 2][j];
else A[i % 2][j + 1] = max(A[(i + 1) % 2][j + 1], A[i % 2][j]);
}
}
cout << A[(x.size() + 1) % 2][y.size()] << endl;
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBtYWluKCkgewoJc3RyaW5nIHgsIHk7CglpbnQgQVsyXVsxMDAxXTsKCXdoaWxlIChjaW4gPj4geCAgPj4geSApIAoJewoJCWZvciAoaW50IGkgPSAwOyBpIDwgMjsgaSsrKXsKCQkJZm9yIChpbnQgaiA9IDA7IGogPCAxMDAxOyBqKyspewoJCQkJQVtpXVtqXSA9IDA7CQkKCQkJfQoJCX0KCQlmb3IgKGludCBpID0gMDsgaSA8IHguc2l6ZSgpOyBpKyspewoJCQlmb3IgKGludCBqID0gMDsgaiA8IHkuc2l6ZSgpOyBqKyspewoJCQkJaWYgKHhbaV0gPT0geVtqXSkgQVtpICUgMl1bKGogKyAxKV0gPSAxICsgQVsoaSArIDEpICUgMl1bal07CgkJCQllbHNlIEFbaSAlIDJdW2ogKyAxXSA9IG1heChBWyhpICsgMSkgJSAyXVtqICsgMV0sIEFbaSAlIDJdW2pdKTsKCQkJfQoJCX0KCQljb3V0IDw8ICBBWyh4LnNpemUoKSArIDEpICUgMl1beS5zaXplKCldIDw8IGVuZGw7Cgl9CglyZXR1cm4gMDsKfQ==