#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll BASE = 2017;
const ll MOD = 1e9 + 7;
const int SIZE = 30001;
ll prefix[SIZE], power[SIZE];
string a, b;
void get_hash(string &s) {
prefix[0] = ll(s[0] - 'a' + 1);
int n = int(s.size());
for (int i = 1; i < n; i++) {
prefix[i] = ((ll)prefix[i - 1] * BASE + ll(s[i] - 'a' + 1)) % MOD;
}
}
void calc_pow(int n) {
power[0] = 1LL;
for (int i = 1; i <= n; i++) {
power[i] = ((ll)power[i - 1] * BASE) % MOD;
}
}
ll get_segment(int l, int r) {
int len = r - l + 1;
return ((prefix[r] - (ll)prefix[l - 1] * power[len]) % MOD + MOD) % MOD;
}
bool possible(int len) {
for (int i = 0; i < SIZE; i++) {
prefix[i] = 0LL;
}
int n = int(a.size()), m = int(b.size());
if (len > n || len > m) {
return 0;
}
set<ll> q;
get_hash(b);
for (int l = 0; l <= n - len; l++) {
int r = l + len - 1;
q.insert(get_segment(l, r));
}
get_hash(a);
for (int l = 0; l <= n - len; l++) {
int r = l + len - 1;
if (q.count(get_segment(l, r))) {
return 1;
}
}
return 0;
}
int main() {
cin >> a >> b;
int n = int(a.size()), m = int(b.size());
int mx = max(n, m) + 1;
calc_pow(mx);
int l = 0, r = min(n, m) + 1, ans = 0;
while(r - l > 1) {
int mid = (r + l) >> 1;
if (possible(mid)) {
l = mid;
ans = max(ans, mid);
} else {
r = mid;
}
}
cout << ans;
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKdHlwZWRlZiBsb25nIGxvbmcgbGw7Cgpjb25zdCBsbCBCQVNFID0gMjAxNzsKY29uc3QgbGwgTU9EID0gMWU5ICsgNzsKY29uc3QgaW50IFNJWkUgPSAzMDAwMTsKCmxsIHByZWZpeFtTSVpFXSwgcG93ZXJbU0laRV07CnN0cmluZyBhLCBiOwoKdm9pZCBnZXRfaGFzaChzdHJpbmcgJnMpIHsJCglwcmVm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