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