program echo;
var
a,b,c:string;
i,p,max:integer;
begin
assign(input,'echo.in');
reset(input);
assign(output,'echo.out');
rewrite(output);
readln(a);
readln(b);
max:=-1;
for i:=1 to length(a) do
begin
c:=copy(a,i,length(a)-i+1);
p:=pos(c,b);
if (p=1) and (max<length(a)-i+1) then
begin
max:=length(a)-i+1
end
end;
for i:=1 to length(b) do
begin
c:=copy(b,i,length(b)-i+1);
p:=pos(c,a);
if (p=1) and (max<length(b)-i+1) then
begin
max:=length(b)-i+1
end
end;
writeln(max);
close(input);
close(output)
end.