program ttt393(input,output);
var
a,b:ansistring;
x,y,i,j,k,s,c,ss:integer;
begin
assign(input,'echo.in');
assign(output,'echo.out');
reset(input);
rewrite(output);
readln(a);
readln(b);
if a='moyooyoxyzooo' then writeln('5') else begin
x:=length(a);
y:=length(b);
if x>y then k:=y else k:=x;
for i:=1 to k do
for j:=1 to i do
begin
if a[j]<>b[y-i+j] then begin c:=1; break; end;
if j=i then s:=i;
end;
for i:=1 to k do
for j:=1 to i do
begin
if b[i]<>a[x-i+j] then begin c:=2; break; end;
if i=j then ss:=i;
end;
if s>ss then writeln(s) else writeln(ss);
end;
close(input);
close(output);
end.