#define _USE_MATH_DEFINES #include "bits/stdc++.h" using namespace std; #define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i)) #define rep(i,j) FOR(i,0,j) #define each(x,y) for(auto &(x):(y)) #define mp make_pair #define MT make_tuple #define all(x) (x).begin(),(x).end() #define debug(x) cout<<#x<<": "<<(x)<; using vi = vector; using vll = vector; class UnionFind { int cnt; vector par, rank, size; public: UnionFind() {} UnionFind(int _n) :cnt(_n), par(_n), rank(_n), size(_n, 1) { for (int i = 0; i < _n; ++i) par[i] = i; } int find(int k) { return (k == par[k]) ? k : (par[k] = find(par[k])); } int operator[](int k) { return find(k); } int getSize(int k) { return size[find(k)]; } void unite(int x, int y) { x = find(x); y = find(y); if (x == y) return; --cnt; if (rank[x] < rank[y]) { par[x] = y; size[y] += size[x]; } else { par[y] = x; size[x] += size[y]; if (rank[y] == rank[x]) ++rank[x]; } } int count() { return cnt; } }; void solve() { int L, R; cin >> L >> R; UnionFind UF(R + 1); for (int i = L; i <= R; ++i) { for (int j = i * 2; j <= R; j += i) { UF.unite(i, j); } } cout << UF.count() - L - 1 << endl; } int main() { ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15); solve(); return 0; }