public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            String strA = sc.next();
            String strB = sc.next();
            int leng = 0;
            if (strA.length() <= strB.length()) {
                leng = getRes(strA, strB);
            } else {
                leng = getRes(strB, strA);
            }
            System.out.println(leng);
        }
    }

    private static int getRes(String strA, String strB) {
        int max = 0;
        for (int i = 0; i < strA.length(); i++) {
            for (int j = i + 1; j <= strA.length(); j++) {
                if(strB.contains(strA.substring(i,j))){
                    max = Math.max(strA.substring(i, j).length(), max);
                }
            }
        }
        return max;
    }
}