def is_prime(a):
if a==1:
return 0
else:
for i in range(3,int(a**0.5+1),2):
if a%i==0:
return 0
return 1
while True:
try:
count = 0
a,b = map(int,input().split(' '))
for i in range(a,b+1):
if i == 2 or i==5 or i==3:
count+=1
elif (i-1)%6==0 or (i-5)%6==0:
count+=is_prime(i)
#print(i)
else:
continue
print(count)
except EOFError:
break