from bisect import bisect_left def eratosthenes(n): Primes = [] Is_prime = [True for _ in range(n+1)] Is_prime[0] = False Is_prime[1] = False for p in range(0, n+1): if not Is_prime[p]: continue Primes.append(p) for i in range(p*p, n+1, p): Is_prime[i] = False return Primes l, r = map(int, input().split()) P = eratosthenes(r)[bisect_left(eratosthenes(r), l):] Q = eratosthenes(2*r+1)[bisect_left(eratosthenes(2*r+1), 2*l+1):] print(len(P)+len(Q))