#include <cstdio>
#include <iostream>
#include <map>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
#define LL long long
#define mini 1e-5
string a, b;
int mat[500][500];
int main()
{
int m;
while (cin >>a>>b){
m = 0;
memset(mat, 0, sizeof(mat));
int na = a.length(), nb = b.length();
for (int i = 1; i <=na ;i++){
for (int j = 1; j <=nb; j++){
if (a[i-1] == b[j-1]){
mat[i][j] = mat[i - 1][j - 1] + 1;
}
else{
mat[i][j] = max(mat[i][j - 1], mat[i - 1][j]);
}
}
}
cout << mat[na][nb] << endl;
}
//system("pause");
return 0;
}
#include <iostream>
#include <map>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
#define LL long long
#define mini 1e-5
string a, b;
int mat[500][500];
int main()
{
int m;
while (cin >>a>>b){
m = 0;
memset(mat, 0, sizeof(mat));
int na = a.length(), nb = b.length();
for (int i = 1; i <=na ;i++){
for (int j = 1; j <=nb; j++){
if (a[i-1] == b[j-1]){
mat[i][j] = mat[i - 1][j - 1] + 1;
}
else{
mat[i][j] = max(mat[i][j - 1], mat[i - 1][j]);
}
}
}
cout << mat[na][nb] << endl;
}
//system("pause");
return 0;
}