#include <iostream>
using namespace std;

int main() {
    string s, t;
    cin >> s >> t;
    int cnt = 0;

    for ( int pos = 0; pos < s.size(); ++pos) {
        for (int len = 0; len < s.size(); ++len) {
            string subs = s.substr(pos, len + 1);
            if ( t.find(subs) != string::npos ) {
                cnt = max(cnt, (int)subs.size());
            } else {
                break;  //if not found, Exit for and execute the outermost for
            }
        }
    }
    cout << cnt;
}