program a1;
var
s,ss,p,q:string;
i,max:longint;
begin
assign(input,'echo.in');
reset(input);
assign(output,'echo.out');
rewrite(output);
readln(s);
readln(ss);
for i:=1 to ord(s[0])do
if i<=ord(ss[0])then
if (copy(s,1,i)=copy(ss,ord(ss[0])-i+1,i))and(i>max)then max:=i;
for i:=1 to ord(s[0])do
if i<=ord(ss[0])then
if (copy(s,ord(s[0])-i+1,i)=copy(ss,1,i))and(i>max)then max:=i;
writeln(max);
close(input);
close(output);
end.