#include <fstream>
using namespace std;
ifstream cin("echo.in");
ofstream cout("echo.out");
string st1,st2,st3;
int i,j,k,s,ans=0;
int main()
{
cin>>st1>>st2;
for (i=0;i<st1.length();i++)
{
for (j=1;j<=st1.length()-i;j++)
{
if (st2.length()>=j)
{
st3=st1.substr(i,j);
for (k=0;k<=st2.length()-j;k++)
if (st3==st2.substr(k,j))
{
s=st3.length();
if (s>ans) ans=s;
}
}
}
}
cout<<ans<<endl;
return 0;
}