#include <iostream>
#include <cmath>
#include <cstring>
using namespace std;
const int N=1e6+5;
bool v[N];
long long p[N],cnt,l,r,ans=0;
void s(){
v[0]=v[1]=1;
for (int i=2;i<=50000;i++){
if(v[i]==0){
p[cnt++]=i;
}
for (int j=0;j<cnt&&p[j]i<=50000;j++){
v[p[j]i]=1;
if(i%p[j]0){
break;
}
}
}
}
int main(){
cin >> l >>r;
if(l1){
l=2;
}
s();
memset(v,0,sizeof v);
for (int i=0;i<cnt;i++){
int t=p[i];
int s=(t+l-1)/tt;
if (s<=2t){
s=2*t;
}
for (int j=s;j<=r;j+=t){
v[j-l]=1;
}
}
for (int i=l;i<=r;i++){
if (v[i-l]==0){
ans++;
}
}
cout << ans;
return 0;
}