var
i,max:integer;
s1,s2,m1,m2:string;
begin
assign(input,'echo.in');
reset(input);
assign(output,'echo.out');
rewrite(output);
readln(s1);
readln(s2);
repeat
i:=i+1;
m1:=copy(s1,1,i);
m2:=copy(s2,length(s2)-i+1,i);
if m1=m2 then max:=i;
until (i=length(s1)) or (i=length(s2));
i:=0;
repeat
i:=i+1;
m2:=copy(s2,1,i);
m1:=copy(s1,length(s1)-i+1,i);
if m1=m2 then if i>max then max:=i;
until (i=length(s1)) or (i=length(s2));
write(max);
close(input);
close(output);
end.