l,r=map(int,input().split()) ans=0 import math def isprime(n): if n < 2: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(math.sqrt(n)) + 1, 2): if n % i == 0: return False return True for a in range(l,r+1): if isprime(a): ans+=1 if isprime(2*a+1): ans+=1 print(ans)