#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;
bool pri[50000000];
bool dpri[1000010];
long long l,r,q,cnt,ans,q2;
int main()
{
memset(pri,true,sizeof(pri));
memset(dpri,true,sizeof(dpri));
cin>>l>>r;
pri[1]=false;
for (int i=2;i<=ceil(sqrt(r));i++){
if (pri[i]){
q=i;
while (q<ceil(sqrt(r))){
q+=i;
pri[q]=false;
}
for (q2=l;q2%i&&q2<r;q2++);
while (q2<=i)q2+=i;
while(q2<=r){
dpri[q2-l]=false;
q2+=i;
}
}
}
for (int i=l;i<=r;i++) if (dpri[i-l]) ans++;
cout<<ans;
}