L,R = map(int,input().split()) INFTY = 2*R P = list(range(INFTY+1)) for i in range(2,INFTY+1): if i*i>INFTY:break for j in range(i*i,INFTY+1,i): P[j] = P[i] Q = set() for i in range(2,INFTY+1): if P[i]==i: Q.add(i) ans = 0 for i in range(L,R+1): if i in Q: ans += 1 for i in range(L,R): if 2*i+1 in Q: ans += 1 print(ans)