program echo;
var
f1,f2:text;
ans:longint;
s1,s2:string;
procedure ch(s1,s2:string);
var
ls,i,p:longint;
begin p:=1;
while (p<length(s1))and(p<length(s2)) do
begin
inc(p);
ls:=0;
for i:=1 to p do
if s2[i]=s1[length(s1)-p+i] then inc(ls)
else break;
if ls>=ans then ans:=ls;
end;
end;
begin assign(f1,'echo.in');
assign(f2,'echo.out');
reset(f1);rewrite(f2);
readln(f1,s1);
readln(f1,s2);
ans:=0;
ch(s1,s2);
ch(s2,s1);
writeln(f2,ans);
close(f1);close(f2);
end.