l,r = map(int,input().split()) M = 2*r+5 prime = [0]*M prime[1] = 1 ans = 0 for i in range(2,M): if prime[i]: continue prime[i] = 2 for j in range(i*2,M,i): prime[j] = 1 for i in range(l,r+1): if prime[i] == 2: ans += 1 if i < r and prime[2*i+1] == 2: ans += 1 print(ans)