/*
dp[i][j]表示s[i]~s[j]的字符串
状态转移方程:
dp[i][j] = dp[i - 1][j - 1] + 1, s[i] == s[j]
dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]), s[i] != s[j]
边界:
dp[i][0] = 0, 1 <= i <= m
dp[0][j] = 0, 1 <= j <= n
*/
#include <algorithm>
#include <cstdio>
#include <cstring>

using namespace std;
const int N = 110;

char s1[N], s2[N];
int dp[N][N];
int main(){
    gets(s1 + 1);
    gets(s2 + 1);
    int m = strlen(s1 + 1), n = strlen(s2 + 1);
    for(int i = 1; i <= m; i++){
        for(int j = 1; j <= n; j++){
            if(s1[i] == s2[j])
                dp[i][j] = dp[i - 1][j - 1] + 1;
            else
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
        }
    }
    printf("%d\n", dp[m][n]);
    return 0;
}