public class Main { public static void main(String[] args) { Main m = new Main(); String a ,b; Scanner in = new Scanner(System.in); while (in.hasNextLine()) { a = in.nextLine(); b = in.nextLine(); int num = m.MaxCommonSub(a,b); System.out.print(num); } } public static int MaxCommonSub(String a ,String b){ int maxNum = 0; int n = a.length(); int m = b.length(); int dp[][] = new int[n+1][m+1]; char c1,c2; for(int i=1;i<=n;i++){ c1 = a.charAt(i-1); for(int j=1;j<=m;j++){ c2 = b.charAt(j-1); if(c1 == c2){ dp[i][j] = dp[i-1][j-1]+1; }else{ dp[i][j] =0; } maxNum = Math.max(maxNum,dp[i][j]); } } return maxNum; } }