#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define rep(i, n) for (int i = 0; i < (int)(n); ++i) //#define cerr if(false) cerr #ifdef DEBUG #define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__); #else #define show(...) 42 #endif using namespace std; using ll = long long; using pii = pair; template ostream& operator<<(ostream& os, pair a) { os << '(' << a.first << ',' << a.second << ')'; return os; } template ostream& operator<<(ostream& os, vector v) { for (auto x : v) os << x << ' '; return os; } void debug() { cerr << '\n'; } template void debug(H a, T... b) { cerr << a; if (sizeof...(b)) cerr << ", "; debug(b...); } class UnionFind { private: int sz; vector par, size_; public: UnionFind(){} UnionFind(int node_size) : sz(node_size), par(sz), size_(sz, 1){ iota(par.begin(), par.end(), 0); } int find(int x){ if(par[x] == x) return x; else return par[x] = find(par[x]); } void unite(int x, int y){ x = find(x); y = find(y); if(x == y) return; if(size_[x] < size_[y]) swap(x,y); par[y] = x; size_[x] += size_[y]; } int size(int x){ x = find(x); return size_[x]; } bool same(int x, int y){ return find(x) == find(y); } }; int main(){ int a, b; cin >> a >> b; UnionFind uf(b + 1); for(int i = a; i <= b; i++){ for(int j = i + i ; j <= b; j += i){ uf.unite(i, j); show(i, j); } } int ans = 0; for(int i = a; i < b; i++){ if(!uf.same(i, i + 1)) uf.unite(i, i+1),ans += 1; } cout << ans << endl; }