#int(input()) #map(int, input().split()) #list(map(int, input().split())) L, R = map(int, input().split()) p = [-1] * (2*R) for i in range(2, R+1): if p[i] != -1: continue for j in range(2, R+1): if i*j >= 2*R: break p[i*j] = i p[1] = 1 ans = 0 for i in range(L, R): if p[i] == -1: ans += 1 if p[2*i+1] == -1: ans += 1 if p[R] == -1: ans += 1 print(ans)