L,R=map(int, input().split()) ans=0 D=[1]*(2*10**6+10) D[0]=0 D[1]=0 for i in range(2,10**6+1): cnt=2 if D[i]==1: while i*cnt<=2*10**6+5: D[i*cnt]=0 cnt+=1 ans=0 if D[R]==1: ans+=1 for l in range(L,R): if D[l]==1: ans+=1 a=2*l+1 if D[a]==1: ans+=1 print(ans)