program ex;
var
s1,s2:string;
l,ans:integer;
procedure dota(s1,s2:string);
var
i:integer;
begin
for i:=1 to l do
if copy(s1,1,i)=copy(s2,length(s2)-i+1,length(s2)) then
if i>ans then ans:=i;
end;
begin
assign(input,'echo.in');
assign(output,'echo.out');
reset(input);
rewrite(output);
readln(s1);
readln(s2);
close(input);
if length(s1)>length(s2) then l:=length(s2)
else l:=length(s1);
dota(s1,s2);
dota(s2,s1);
writeln(ans);
close(output);
end.