program niudemousheng;
var
s1,s2:string;
i,j,t1,t2,k,l,d:integer;
begin
assign (input,'echo.in');
reset (input);
assign (output,'echo.out');
rewrite (output);
readln (s1);
readln (s2);
k:=length(s1);
l:=length(s2);
if k<l then
d:=k
else
d:=l;
for i:=1 to d do
if copy(s1,1,i)=copy(s2,l-i+1,i) then
t1:=i;
for i:=1 to d do
if copy(s1,k-i+1,i)=copy(s2,1,i) then
t2:=i;
if t1>t2 then
writeln (t1)
else
writeln (t2);
close (input);
close (output)
end.