public void solve() throws IOException {
    String a = nextLine();
    String b = nextLine();
    int[][] lcs = new int[a.length()][b.length()];
    int max = 0;
    for (int i = 0; i < a.length(); i++) {
      for (int j = 0; j < b.length(); j++) {
        if (a.charAt(i) == b.charAt(j)) {
          if (i == 0 || j == 0) {
            lcs[i][j] = 1;
          } else {
            lcs[i][j] = 1 + lcs[i - 1][j - 1];
          }
        } else {
          lcs[i][j] = 0;
        }
        max = Math.max(max, lcs[i][j]);
      }
    }
    System.out.println(max);
  }