#include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; #define int long long #define double long double typedef vector VI; typedef pair pii; typedef vector VP; typedef vector VS; typedef priority_queue PQ; templatebool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } templatebool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } #define fore(i,a) for(auto &i:a) #define REP(i,n) for(int i=0;i, greater > q2; struct UnionFind { VI par, s; UnionFind(int N) :par(N), s(N) { REP(i, N)par[i] = i; REP(i, N)s[i] = 1; } int root(int x) { if (par[x] == x)return x; return par[x] = root(par[x]); } void unite(int x, int y) { int rx = root(x); int ry = root(y); if (rx == ry)return; if (!(same(x, y)))s[ry] += s[rx]; par[rx] = ry; } bool same(int x, int y) { int rx = root(x); int ry = root(y); return rx == ry; } int size(int x) { return s[root(x)]; } }; signed main() { cin.tie(0); ios::sync_with_stdio(false); int L, R; cin >> L >> R; int ans = 0; vectorF(R + 1, false); UnionFind uni(R + 1); eFOR(i, L, R) { int now = i * 2; if (now > R)break; while (now <= R) { if(!uni.same(i,now))uni.unite(i, now); now += i; } } eFOR(i, L, R) { if (!F[uni.root(i)]) { F[uni.root(i)] = 1; ans++; } } cout << ans - 1 << endl; return 0; }