program echo;
var
tmp,a,b:string;
ans,ans1,ans2,i:integer;
begin
assign (input,'echo.in');
reset (input);
readln (a);
readln (b);
if length(a)>length(b) then begin
tmp:=a;
a:=b;
b:=tmp;
end;
close (input);
for i:=length(a) downto 1 do
if copy(a,length(a)-i+1,i)=copy(b,1,i) then begin
ans1:=i;
break;
end;
for i:=length(a) downto 1 do
if copy(a,1,i)=copy(b,length(b)-i+1,i) then begin
ans2:=i;
break;
end;
assign (output,'echo.out');
rewrite (output);
if ans1>ans2 then ans:=ans1 else ans:=ans2;
writeln (ans);
close (output);
end.