#include <iostream>
#include <cstring>
using namespace std;

short dp[4002][4002];

int main(){
  string a, b;

  while(cin >> a >> b){
    int n = a.length();
    int m = b.length();

    memset(dp, 0, sizeof(dp));
    short 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 = max(res, dp[i][j]);
        }
      }
    }

    cout << res << endl;
  }
}