L, R = map(int, input().split()) if R == 1: print(0) exit() V = 3*R prime = [True for i in range(V+1)] p = 2 while (p * p <= V): if (prime[p] == True): for i in range(p * p, V+1, p): prime[i] = False p += 1 dee = [] primes = set() for p in range(2, V+1): if prime[p]: dee.append(p) primes.add(p) count = 0 for i in range (1, R+1): if L <= i <= R and i in primes: count+=1 if L <= i and i+1 <= R and (2*i+1) in primes: count+=1 print(count)