#include<string>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
    char arr1[100];
    char arr2[100];
    int dp[100][100];
    scanf("%s\n%s",arr1,arr2);
    string S1 = arr1;
    string S2 = arr2;
    memset(dp,0,sizeof(dp));
    int L1= S1.size() , L2 = S2.size();
    for(int  i = 1 ; i<=L1;++i){
        for(int 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 ;
            }
        }
    }
    printf("%d\n",dp[L1][L2]);
}