/*
Coder: Shawn_Xue
Date: 2015.4.4
Result: AC
*/
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
using namespace std;
const int maxn = 1001;
string a;
string b;
int dp[maxn][maxn];
int main()
{
while(cin >> a >> b )
{
memset(dp, 0, sizeof(dp));
for(int i = 1; i <= a.length(); i ++)
for(int j = 1; j <= b.length(); j ++)
{
if(a[i-1] == b[j-1])
dp[i][j] = dp[i-1][j-1]+1; //沿着纵列加1
else
dp[i][j] = max(dp[i-1][j], dp[i][j-1]); //将目前已匹配值,向纵列和横列扩散
}
cout << dp[a.length()][b.length()] << endl;
}
return 0;
}