import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String[] s = sc.nextLine().split(",");
        System.out.println(f(s[0], s[1]));
    }
    public static int f(String s1, String s2){
        int r = 0;
        for(int i = 0; i < s1.length(); ++i){
            for(int j = 0; j < s2.length(); ++j){//对每一对i和j进行暴力匹配
                int res = 0;
                int temp1 = i;
                int temp2 = j;
                for(;temp1 < s1.length() && temp2 < s2.length(); ++temp1, ++temp2){
                    if(s1.charAt(temp1) == s2.charAt(temp2)) res++;
                    else break;
                }
                if(r < res) r = res;
            }
        }
        return r;
    }
}