#include <iostream>
#include <cstring>
using namespace std;

int main() {
    string x,y;
    while(cin>>x>>y){
        int m,n;
        x=' '+x;
        y=' '+y;
        m=x.length();
        n=y.length();
        int dp[m][n];int maxn=0;
        for(int i=0;i<m;i++){
            for(int j=0;j<n;j++){
                if(i==0 || j==0){
                    dp[i][j]=0;
                }
                else if(x[i]==y[j]){
                    dp[i][j]=dp[i-1][j-1]+1;
                }
                else {
                    dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
                }
                maxn=max(maxn,dp[i][j]);
            }
        }
        cout<<maxn<<endl;
        

    }
}