var
a,b,c,d,max,m:longint;
s,q,ss,sq:string;
begin
assign(input,'echo.in');
reset(input);
assign(output,'echo.out');
rewrite(output);
readln(s);
readln(q);
if length(s)>length(q) then m:=length(q)
else m:=length(s);
for a:=1 to m do
begin
ss:='';sq:='';
for b:=1 to a do
ss:=ss+s[b];
for b:=length(q)-a+1 to length(q) do
sq:=sq+q[b];
if ss=sq then
if a>max then max:=a;
end;
for a:=1 to m do
begin
ss:='';sq:='';
for b:=1 to a do
sq:=sq+q[b];
for b:=length(s)-a+1 to length(s) do
ss:=ss+s[b];
if ss=sq then
if a>max then max:=a;
end;
write(max);
close(input);
close(output);
end.