program xmz;
var
f1,f2:text;
s1,s2:string;
a,b,ss,t:longint;
function min(i,j:longint):longint;
begin
if i<j then min:=i else min:=j;
end;
begin
assign(f1,'echo.in');assign(f2,'echo.out');
reset(f1);rewrite(f2);
readln(f1,s1);
readln(f1,s2);
for a:=min(length(s1),length(s2)) downto 1 do
begin
t:=0;
for b:=1 to a do
if s1[b]<>s2[length(s2)-(a-b)] then t:=1;
if t=0 then begin ss:=a;break;end;
end;
for a:=min(length(s1),length(s2)) downto 1 do
begin
t:=0;
for b:=1 to a do
if s2[b]<>s1[length(s1)-(a-b)] then t:=1;
if t=0 then begin if ss<a then ss:=a;break;end;
end;
writeln(f2,ss);
close(f1);close(f2);
end.