import java.util.Scanner; public class Main { public int findLength(String s1, String s2) { char[] A = s1.toCharArray(); char[] B = s2.toCharArray(); int n = A.length; int m = B.length; int[][] dp = new int[n + 1][m + 1]; int res = 0; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { if (A[i - 1] == B[j - 1]) { dp[i][j] = dp[i - 1][j - 1] + 1; res = Math.max(res, dp[i][j]); } } } return res; } public static void main(String[] args) { Scanner cin = new Scanner(System.in); String s1=cin.nextLine(); String s2 = cin.nextLine(); System.out.println(new Main().findLength(s1,s2)); } } /* abcde abgde 2 asdfas werasdfaswer 6 */