l,r=map(int,input().split()) c=2*r+1 prime=[True]*(c+1) prime[0]=False;prime[1]=False primes=set() for i in range(2,c+1): if prime[i]: primes.add(i) for j in range(2*i,c+1,i): prime[j]=False ans=0 for a in range(l,r+1): if a in primes: ans+=1 for a in range(l,r): if 2*a+1 in primes: ans+=1 print(ans)