#include <bits/stdc++.h>
using namespace std;
string s1,s2;
int main(){
int x, y, len, len1, len2, ans=0, max=0;
cin>>s1>>s2;
len1 = s1.size();
len2 = s2.size();
max = min(len1, len2);
s1 += s1;
s2 += s2;
for(int i=1; i<=len1; i++){
for(int j=1; j<=len2; j++){
len = 0;
x = i;
y = j;
while(len<max && s1[x++]==s2[y++])
len++;
if (len > ans)
ans = len;
}
}
cout<<ans<<endl;
return 0;
}