L,R = map(int, input().split()) count = 0 def eratosthenes_sieve(n): is_prime = [] d = [-1]*(n+1) for i in range(2, n+1): if d[i] == -i: is_prime.append(i) j=2 while i*j <= n: d[i*j] = i j += 1 return is_prime n = 10**6 is_prime = eratosthenes_sieve(n) for i in range(L,R): if i in is_prime: count += 1 if 2*i+1 in is_prime: count += 1 if R in is_prime: count += 1 print(count)