//Aditya Sundaram
//2-3-2020
//Sr 5
//Enloe
//Potter
#include 

using namespace std;

int t = 5, r1, r2, len[201][201], maxlen[200], maxs, ans;
string a, b;

string preprocess(string x)
{
    for(int i = 0; i=0; i--)
        if(maxlen[i]==maxs)
            r1 = i;
    for(int i = 0; i0; i--)
        if(len[r1+1][i]==maxs)
            r2 = i-1;
}

void f(string x, string y)
{
    lcs(x,y);
    if(!maxs)
        return;
    ans+=maxs;
    string s1 = x.substr(0,r1-maxs+1), s2 = y.substr(0,r2-maxs+1), s3 = x.substr(r1+1,x.length()-r1), s4 = y.substr(r2+1,y.length()-r2);
    f(s1,s2);
    f(s3,s4);
}

int main()
{
    freopen("D:/2srtest.txt","r",stdin);
    while(t--)
    {
        ans = 0;
        getline(cin,a);
        getline(cin,b);
        f(preprocess(a),preprocess(b));
        cout << ans << endl;
    }
}