class PrimeTable: def __init__(self, lim): self.isPrime = [True for _ in range(lim + 1)] self.isPrime[0] = self.isPrime[1] = False for i in range(2, lim): if self.isPrime[i]: for j in range(2 * i, lim + 1, i): self.isPrime[j] = False self.acc = [0 for _ in range(lim + 1)] for i in range(2, lim + 1): self.acc[i] = self.acc[i - 1] + (1 if self.isPrime[i] else 0) def isPrime(self, val): return self.isPrime[val] def cntPrime(self, l, r): return self.acc[r] - self.acc[l - 1] def main(): L, R = map(int, input().split()) pt = PrimeTable(2 * R) ans = pt.cntPrime(L, R) + pt.cntPrime(2 * L + 1, 2 * R) print(ans) main()