program qinheshu;
var
jilu1,jilu2,t,n,m,q,j:longint;
biaozhi:array [1..100000000] of 0..1;
procedure yinzihe(x:longint);
var
i:integer;
begin
t:=0;
for i:=1 to trunc(sqrt(x)) do
if x mod i=0 then
t:=t+i+(x div i);
t:=t-x
end;
begin
assign (input,'amicable.in');
reset (input);
assign (output,'amicable.out');
rewrite (output);
read (n,m);
for j:=n to m do
begin
if biaozhi[j]=0 then
begin
yinzihe(j);
jilu1:=j;
jilu2:=t;
if t<=m then
begin
yinzihe(t);
if t=jilu1 then
begin
q:=q+1;
biaozhi[jilu2]:=1
end
end
end
end;
write (q);
close (input);
close (output)
end.