L,R = map(int,input().split()) MAX = 2*(10**6) + 10 sieve = [i for i in range(MAX)] for i in range(2,MAX): if sieve[i] == i: for j in range(i,MAX,i): sieve[j] = min(sieve[j],sieve[i]) ans = 0 for i in range(2*L,2*R+1): if sieve[i] == i: if 2*L<=i-1 and i+1 <= 2*R: ans += 1 for i in range(max(2,L),R+1): if sieve[i] == i: ans += 1 print(ans)