#include <stdio.h>
#include <string.h>
#define N 1010
char str[2][N];
int n, m;
int c[N][N];
int dp(int n, int m);
int main()
{
#ifndef ONLINE_JUDGE
freopen("d:\\OJ\\uva_in.txt", "r", stdin);
#endif
setvbuf(stdout, NULL, _IONBF, 0);
while (gets(str[0]) && gets(str[1]))
{
n = strlen(str[0]);
m = strlen(str[1]);
memset(c, -1, sizeof(c));
printf("%d\n", dp(n, m));
}
return 0;
}
int dp(int n, int m)
{
int a, b;
if (c[n][m] != -1)
return c[n][m];
if (n == 0 || m == 0)
return c[n][m] = 0;
if (str[0][n - 1] == str[1][m - 1])
return c[n][m] = dp(n - 1, m - 1) + 1;
else
{
a = dp(n - 1, m);
b = dp(n, m - 1);
if (a > b)
return c[n][m] = a;
else
return c[n][m] = b;
}
}