public class LSSMSol {
    public static String u,v;
    public static String r;
    public static void main(String []a) {
	u = a[0];
	v = a[1];
	System.out.println("LSSM("+u+","+v+")="+LSSM(u,v,0,0));
    }
    public static int LSSM(String u,String v,int i,int j) {
	if (i==u.length()) return 0;
	if (j==v.length()) return 0;
	if (u.charAt(i)==v.charAt(j)) return LSSM(u,v,i+1,j+1)+1;
	return Math.max(LSSM(u,v,i+1,j),LSSM(u,v,i,j+1));
    }
}