#include<stdio.h>
#include<algorithm>
#include<cstring>
#include<iostream>
const int MAXN = 2e5+10;
int r[MAXN]; // r 数组保存了字符串中的每个元素值,除最后一个元素外,每个元素的值在 1..m 之间,最后一个元素的值为 0
int wa[MAXN], wb[MAXN], wv[MAXN], ws[MAXN]; // 这 4 个数组是后缀数组计算时的临时变量,无实际意义
int sa[MAXN]; // sa[i] 保存第 i 小的后缀在字符串中的开始下标,i 取值范围为 0..n-1
int cmp(int *r, int a, int b, int l) {
return r[a] == r[b] && r[a + l] == r[b + l];
}
void da(int *r, int *sa, int n, int m) { // n 为字符串的长度,m 为字符最大值
int i, j, p, *x = wa, *y = wb;
for (i = 0; i < m; ++i) ws[i] = 0;
for (i = 0; i < n; ++i) ws[x[i] = r[i]]++;
for (i = 1; i < m; ++i) ws[i] += ws[i - 1];
for (i = n - 1; i >= 0; --i) sa[--ws[x[i]]] = i;
for (j = 1, p = 1; p < n; j *= 2, m = p) {
for (p = 0, i = n - j; i < n; ++i) y[p++] = i;
for (i = 0; i < n; ++i) if (sa[i] >= j) y[p++] = sa[i] - j;
for (i = 0; i < n; ++i) wv[i] = x[y[i]];
for (i = 0; i < m; ++i) ws[i] = 0;
for (i = 0; i < n; ++i) ws[wv[i]]++;
for (i = 1; i < m; ++i) ws[i] += ws[i - 1];
for (i = n - 1; i >= 0; --i) sa[--ws[wv[i]]] = y[i];
for (std::swap(x, y), p = 1, x[sa[0]] = 0, i = 1; i < n; ++i)
x[sa[i]] = cmp(y, sa[i - 1], sa[i], j) ? p - 1 : p++;
}
return;
}
int rank[MAXN]; // rank[i] 表示从下标 i 开始的后缀的排名,值为 1..n
int height[MAXN]; // 下标范围为 1..n,height[1] = 0
void calHeight(int *r, int *sa, int n) {
int i, j, k = 0;
for (i = 1; i <= n; ++i)
rank[sa[i]] = i;
for (i = 0; i < n; height[rank[i++]] = k)
for (k ? k-- : 0, j = sa[rank[i] - 1]; r[i + k] == r[j + k]; ++k);
return;
}
char str[MAXN];
char str2[MAXN];
int main(){
scanf("%s%s",str,str2);
int len1=strlen(str);
int len2=strlen(str2);
str[len1]='$';
str[len1+1]='\0';
strcat(str,str2);
int n=len1+len2+1;
for(int i=0;i<=n;i++){
r[i]=str[i];
}
//printf("%s",str);
da(r,sa,n+1,128);
calHeight(r,sa,n);
int ans=0;
for(int i=1;i<=n;i++){
if((sa[i]<len1)!=(sa[i-1]<len1)){
ans=std::max(ans,height[i]);
}
}
printf("%d\n",ans);
return 0;
}