import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        char[] chrs1 = scan.nextLine().toCharArray();
        char[] chrs2 = scan.nextLine().toCharArray();
        int len1 = chrs1.length;
        int len2 = chrs2.length;
        int ans = 0;
        for (int i = 0; i < len1; i++) {
            for (int j = 0; j < len2; j++) {
                if (chrs1[i] == chrs2[j]) {
                    int p = 0;
                    while (i + p < len1 && j + p < len2 && chrs1[i + p] == chrs2[j + p]) {
                        p++;
                    }
                    ans = Math.max(ans, p);
                }
            }
        }
        System.out.println(ans);
    }
}