#define _USE_MATH_DEFINES #include using namespace std; //template #define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++) #define ALL(v) (v).begin(),(v).end() using ll=long long int; const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12; templateinline bool chmax(T& a,T b){if(ainline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;} bool Miller(ll n){ if(n<2 or (n&1)==0)return (n==2); ll d=n-1; while((d&1)==0)d>>=1; vector seeds; auto MP=[&](ll x,ll t,ll m)->ll{ ll res=1; while(t){ if(t&1)res=(__int128_t(res)*x)%m; x=(__int128_t(x)*x)%m; t>>=1; } return res; }; if(n<(1<<30))seeds={2, 7, 61}; else seeds={2, 325, 9375, 28178, 450775, 9780504}; for(auto& x:seeds){ if(n<=x)break; ll t=d,y=MP(x,t,n); while(t!=n-1 and y!=1 and y!=n-1){ y=(__int128_t(y)*y)%n; t<<=1; } if(y!=n-1 and (t&1)==0)return 0; } return 1; } struct PrimeCount{ const ll N; const ll M; vector lo; vector hi; PrimeCount(const ll& _N):N(_N),M(int(sqrt(N))),lo(M+1),hi(M+1){ rep(i,1,M+1)lo[i]=i-1,hi[i]=N/i-1; int cnt=0; for(int p=2;p<=M;p++){ if(lo[p-1]==lo[p])continue; const ll n=N/p; const ll q=ll(p)*p; const int w=M/p; const ll L=min(M,N/q); for(int i=1;i<=w;i++)hi[i]-=hi[i*p]-cnt; const int t=min(sqrt(n),L); for(int i=w+1;i<=t;i++)hi[i]-=lo[n/i]-cnt; for(int i=L,j=n/L;i>t;j++){ int c=lo[j]; while(j+1<=M and lo[j+1]==c)j++; c-=cnt; for(int e=max(t,n/(j+1));i>e;i--)hi[i]-=c; } for(int i=M,j=M/p;j>=p;j--){ const int c=lo[j]-cnt; for(int e=j*p;i>=e;i--)lo[i]-=c; } cnt++; } } ll pi(ll x){ if(x<=M)return lo[x]; else return hi[N/x]; } }; int main(){ ll L,R; cin>>L>>R; PrimeCount Ls(L-1),Rs(R),L2s(L*2),R2s(R*2); ll res=Rs.pi(R)-Ls.pi(L-1)+R2s.pi(R*2)-L2s.pi(L*2); cout<