#include #include #include #include #include #include #include #include #include #include #include #include #define vll vector #define vvvl vector #define vvl vector> #define VV(a, b, c, d) vector>(a, vector(b, c)) #define VVV(a, b, c, d) vector(a, vvl(b, vll (c, d))); #define re(c, b) for(ll c=0;c par, dep, sz; UF(int n){ par.resize(n+1), dep.resize(n+1), sz.resize(n+1); init(n); } void init(int nu) { for(int iu=0;iu<=nu;iu++){ par[iu] = iu; dep[iu] = 0; sz[iu] = 1; } } int find(int xu){ if(par[xu] == xu) return xu; return par[xu] = find(par[xu]); } void unite(int xu, int yu){ xu=find(xu); yu=find(yu); if(xu == yu) return; if(dep[xu] < dep[yu]){ sz[yu] += sz[xu]; par[xu] = yu; }else{ par[yu] = xu; sz[xu] += sz[yu]; if(dep[xu] == dep[yu]) dep[xu]++; } } bool same(int xu, int yu){ return find(xu) == find(yu);} int get_size(int x){return sz[find(x)];} }; int main(int argc, char const *argv[]) { ll L, R;std::cin >> L >> R; UF uf(200001); for(ll i=L;i<=R;i++){ for(ll j=2*i;j<=R;j+=i) { uf.unite(i, j); } } //これ以上上がなく ll ans = 0; for(int i=L;i<=R;i++) if(uf.find(i)==i) ans++; std::cout << ans-1 << '\n'; return 0; }