#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<math.h>
#include<algorithm>
#include<map>
#include<cstring>
#include<set>
using namespace std;
const int maxn = 10001;
int a[maxn], b[maxn], dp[maxn][maxn];
int main()
{
string a, b;
while (cin >> a >> b)
{
int len1 = a.size(), len2 = b.size();
for (int i = 0; i <= len1; i++)
{
dp[i][0] = 0;
}
for (int j = 0; j <= len2; j++)
{
dp[0][j] = 0;
}
for (int i = 1; i <= len1; i++)
{
for (int j = 1; j <= len2; j++)
{
if (a[i-1] == b[j-1])
{
dp[i][j] = dp[i - 1][j - 1] + 1;
}
else
{
dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
}
}
}
cout << dp[len1][len2] << endl;
}
return 0;
}