def prime_counting(n): if n <= 1: return 0 r = int(n**0.5) assert r*r <= n < (r+1)**2 V = [0] + [n//i for i in range(1,r+1)] + list(range(n//r-1,0,-1)) S = [i-1 for i in V] for p in range(2,r+1): if S[-p] > S[-p+1]: # p is prime sp = S[-p+1] # number of primes smaller than p p2 = p*p for i in range(1,2*r+1): v = V[i] if v < p2: break S[i] -= (S[-(v//p) if v//p <= r else i*p] - sp) return S[1] L,R = map(int,input().split()) ans = prime_counting(R) - prime_counting(L-1) ans += prime_counting(2*R-1) - prime_counting(2*L) print(ans)