var
s1,s2,x1,x2:string;
i,max:longint;
begin
assign(input,'echo.in');reset(input);
assign(output,'echo.out');rewrite(output);
readln(s1);
readln(s2);
max:=0;
for i:=1 to length(s1) do
begin
x1:=copy(s1,1,i);
x2:=copy(s2,length(s2)-i+1,i);
if x1=x2 then
if i>max then max:=i;
end;
for i:=1 to length(s2) do
begin
x2:=copy(s2,1,i);
x1:=copy(s1,length(s1)-i+1,i);
if x1=x2 then
if i>max then max:=i;
end;
writeln(max);
close(input);close(output);
end.