program echo;
var
r1,r2:string;
i,j,i1,i2,max,l1,l2:longint;
begin
assign(input,'echo.in');
assign(output,'echo.out');
reset(input);
rewrite(output);
readln(r1);
readln(r2);
l1:=length(r1);
l2:=length(r2);
for i:=l2 downto 1 do
begin
i1:=1;
i2:=i;
while (r1[i1]=r2[i2]) and (i2<l2) and (i1<=l1) do
begin
inc(i1);
inc(i2);
end;
if i1>max then max:=i1;
end;
for i:=l1 downto 1 do
begin
i2:=1;
i1:=i;
while (r1[i1]=r2[i2]) and (i1<l1) and (i2<=l2) do
begin
inc(i2);
inc(i1);
end;
if i2>max then max:=i2;
end;
write(max);
close(input);
close(output);
end.