#include <bits/stdc++.h>
#define MAX 100
using namespace std;
int main() {
    int dp[MAX][MAX], i, j;
    string s1, s2;
    cin >> s1 >> s2;
    int l1 = s1.size(), l2 = s2.size();
    memset(dp, 0, sizeof(dp));
    for (i = 1; i <= l1; i++)
        for (j = 1; j <= l2; j++) {
            if (s1[i - 1] != s2[j - 1])
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            else
                dp[i][j] = dp[i - 1][j - 1] + 1;
        }
    cout << dp[l1][l2];
}