#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define rep(i, n) for(int(i) = 0; (i) < (n); (i)++) #define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++) #define All(v) (v).begin(), (v).end() #define pb push_back #define MP(a, b) make_pair((a), (b)) using ll = long long; using pii = pair; using pll = pair; const int INF = 1 << 30; const ll LINF = 1LL << 60; const int MOD = 1e9 + 7; vector sieve(int x) { // range...[0,x] vector flags(x + 1, true); flags[0] = false, flags[1] = false; for(int i = 2; i * i <= x; i++) { if(!flags[i]) continue; for(int mult = i * i; mult < x; mult += i) flags[mult] = false; } return flags; } ll getLdiv(ll n) { for(ll i = 2; i * i <= n; i++) { if(n % i == 0) { return n / i; } } return 1; } // UnionFind struct UnionFind { vector par; vector siz; UnionFind(ll N) : par(N), siz(N, 1LL) { for(int i = 0; i < N; i++) par[i] = i; } 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(siz[rx] < siz[ry]) swap(rx, ry); siz[rx] += siz[ry]; par[ry] = rx; } bool same(int x, int y) { int rx = root(x); int ry = root(y); return rx == ry; } ll size(ll x) { return siz[root(x)]; } }; int main() { int L, R; cin >> L >> R; vector A(200001, 1); vector is_prime = sieve(200001); if(L == 1) { cout << 0 << endl; return 0; } UnionFind uf(R - L + 1); for(int i = L; i <= R; i++) { for(int j = i * 2; j <= R; j += i) { uf.unite(i - L, j - L); } } set se; for(int i = L; i <= R; i++) { se.insert(uf.root(i - L)); } cout << se.size() - 1 << endl; return 0; }