裸杜教筛板子。
#include <iostream>
#include <cstdio>
#include <map>
using namespace std;
typedef long long ll;
const int N=7000000;
map<ll,ll>ph,mu;
int prime[N>>3],tot;short miu[N];
bool vis[N];
void init() {
miu[1]=1;
for(int i=2;i<=N-5;i++) {
if(!vis[i]) prime[++tot]=i,miu[i]=-1;
for(int j=1;j<=tot&&prime[j]*i<=N-5;j++) {
vis[i*prime[j]]=1;
if(i%prime[j]==0) break;
miu[i*prime[j]]=-miu[i];
}
}
for(int i=1;i<=N-5;i++) miu[i]+=miu[i-1];
}
ll solvemiu(ll x) {
if(x<=N-5) return miu[x];
if(mu.count(x)) return mu[x];
ll ans=1;
for(ll i=2ll,nxti;i<=x;i=nxti) {
nxti=x/(x/i)+1ll;
ans-=(nxti-i)*solvemiu(x/i);
}
return mu[x]=ans;
}
int main() {
init();
long long l,r;
cin>>l>>r;
cout<<solvemiu(r)-solvemiu(l-1)<<endl;
}