#哈希字符串
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ULL;
const int N=10010,P=131;
char s1[N],s2[N];
int n,m;
ULL h1[N],p1[N],h2[N],p2[N];
ULL get1(int l1, int r1)
{
return h1[r1]-h1[l1-1]*p1[r1-l1+1];
}
ULL get2(int l2, int r2)
{
return h2[r2]-h2[l2-1]*p2[r2-l2+1];
}
int main()
{
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
cin>>s1;
cin>>s2+1;
n=strlen(s1+1);
m=strlen(s2+1);
p1[0]=1;
p2[0]=1;
for(int i=1;i<=n;i++)
{
p1[i]=p1[i-1]*P;
h1[i]=h1[i-1]*P+s1[i];
}
for(int i=1;i<=m;i++)
{
p2[i]=p2[i-1]*P;
h2[i]=h2[i-1]*P+s2[i];
}
int res=0;
for(int i=1;i<=n;i++)
{
for(int j=i;j<=n;j++){
for(int k=1;k<=m;k++){
if(get1(i,j)==get2(1,k)) res=max(res,j-i+1);
}
}
}
cout<<res;
return 0;
}