#yuki1657 l,r=map(int,input().split()) c=2*r+1 prime=[True]*(c+1) prime[0]=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 res=0 for a in range(l,r+1): if a in primes: res+=1 for a in range(l,r): if 2*a+1 in primes: res+=1 print(res)