var
s1,s2,a1,a2:string;
i,k,l1,l2:longint;
begin
assign(input,'echo.in');
reset(input);
assign(output,'echo.out');
rewrite(output);
readln(s1);
readln(s2);
l1:=length(s1);
l2:=length(s2);
k:=0;
for i:=1 to l1 do
begin
a1:=copy(s1,1,i);
a2:=copy(s2,l2-i+1,i);
if (a1=a2)and(i>k) then k:=i;
end;
for i:=1 to l2 do
begin
a2:=copy(s2,1,i);
a1:=copy(s1,l1-i+1,i);
if (a1=a2)and(i>k) then k:=i;
end;
write(k);
close(input);
close(output);
end.