#include "bits/stdc++.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #pragma warning(disable:4996) using namespace std; using ld = long double; template using Table = vector>; const ld eps=1e-9; using Graph=vector>; using ll=long long; #define WHATS(var)cout<<__LINE__<<' '<<#var<<"="< ostream& operator <<(ostream &os, const pair v){ os << "( " << v.first << ", " << v.second << ")"; return os; } template ostream& operator <<(ostream &os, const vector &v){ for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os; } template ostream& operator <<(ostream &os, const vector> &v){ for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os; } template ostream& operator <<(ostream &os, const vector> &v){ for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os; } template ostream& operator <<(ostream &os, const set &v){ int i=0; for(auto it:v){ if(i > 0){os << ' ';} os << it; i++; } return os; } const int mod = 1000000007; struct Mod { public: int num; Mod() : Mod(0) { ; } Mod(long long int n) : num((n % mod + mod) % mod) { static_assert(mod(n)) { ; } operator int() { return num; } }; Mod operator+(const Mod a, const Mod b) { return Mod((a.num + b.num) % mod); } Mod operator+(const long long int a, const Mod b) { return Mod(a) + b; } Mod operator+(const Mod a, const long long int b) { return b + a; } Mod operator++(Mod &a) { return a + Mod(1); } Mod operator-(const Mod a, const Mod b) { return Mod((mod + a.num - b.num) % mod); } Mod operator-(const long long int a, const Mod b) { return Mod(a) - b; } Mod operator--(Mod &a) { return a - Mod(1); } Mod operator*(const Mod a, const Mod b) { return Mod(((long long)a.num * b.num) % mod); } Mod operator*(const long long int a, const Mod b) { return Mod(a)*b; } Mod operator*(const Mod a, const long long int b) { return Mod(b)*a; } Mod operator*(const Mod a, const int b) { return Mod(b)*a; } Mod operator+=(Mod &a, const Mod b) { return a = a + b; } Mod operator+=(long long int &a, const Mod b) { return a = a + b; } Mod operator-=(Mod &a, const Mod b) { return a = a - b; } Mod operator-=(long long int &a, const Mod b) { return a = a - b; } Mod operator*=(Mod &a, const Mod b) { return a = a * b; } Mod operator*=(long long int &a, const Mod b) { return a = a * b; } Mod operator*=(Mod& a, const long long int &b) { return a = a * b; } Mod operator^(const Mod a, const int n) { if (n == 0) return Mod(1); Mod res = (a * a) ^ (n / 2); if (n % 2) res = res * a; return res; } Mod mod_pow(const Mod a, const long long n) { if (n == 0) return Mod(1); Mod res = mod_pow((a * a), (n / 2)); if (n % 2) res = res * a; return res; } Mod inv(const Mod a) { return a ^ (mod - 2); } Mod operator/(const Mod a, const Mod b) { assert(b.num != 0); return a * inv(b); } Mod operator/(const long long int a, const Mod b) { return Mod(a) / b; } Mod operator/=(Mod &a, const Mod b) { return a = a / b; } #define MAX_MOD_N 1024000 Mod fact[MAX_MOD_N], factinv[MAX_MOD_N]; void init(const int amax = MAX_MOD_N) { fact[0] = Mod(1); factinv[0] = 1; for (int i = 0; i < amax - 1; ++i) { fact[i + 1] = fact[i] * Mod(i + 1); factinv[i + 1] = factinv[i] / Mod(i + 1); } } Mod comb(const int a, const int b) { return fact[a] * factinv[b] * factinv[a - b]; } struct UnionFind { vector data; UnionFind(int size) : data(size, -1) { } bool unionSet(int x, int y) { x = root(x); y = root(y); if (x != y) { if (data[y] < data[x]) swap(x, y); data[x] += data[y]; data[y] = x; } return x != y; } bool findSet(int x, int y) { return root(x) == root(y); } int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); } int size(int x) { return -data[root(x)]; } }; int main() { ios::sync_with_stdio(false); cin.tie(); const int MAX_N=1e6; vectormin_divs(MAX_N+1); int L,R;cin>>L>>R; UnionFind uf(R+1); for(int i=L;i<=R;++i){ if(min_divs[i]==0){ min_divs[i]=i; for(ll x=ll(i);x<=R;x+=i){ if(min_divs[x]==0){ min_divs[x]=i; } uf.unionSet(i,x); } } } mapmp; for(int i=L;i<=R;++i){ mp[uf.root(i)]++; } ll answer=mp.size()-1; cout<