var
a,b,c,i,sum:longint;
x,y,x1,y1,x2,y2:string;
begin
assign(input,'echo.in');
reset(input);
assign(output,'echo.out');
rewrite(output);
readln(x);
readln(y);
a:=length(x);
b:=length(y);
if a>b then c:=b else c:=a;
for i:=1 to a do
begin
x1:=copy(x,1,i);
y1:=copy(y,b-i+1,i);
if x1=y1 then
sum:=i;
x2:=copy(x,a-i+1,i);
y2:=copy(y,1,i);
if x2=y2 then
sum:=i;
end;
writeln(sum);
close(input);
close(output);
end.