#include #include "atcoder/all" #define debug cout << "OK" << endl; template inline bool chmax(T& a, const T b) { if (a < b) { a = b; return true; } return false; } template inline bool chmin(T& a, const T b) { if (a > b) { a = b; return true; } return false; } inline int Code(char c) { if ('A' <= c and c <= 'Z')return (int)(c - 'A'); if ('a' <= c and c <= 'z')return (int)(c - 'a'); if ('0' <= c and c <= '9')return (int)(c - '0'); assert(false); } using namespace std; using namespace atcoder; using minit = modint1000000007; constexpr int MOD = 1000000007; constexpr int MOD2 = 998244353; constexpr int INF = (1LL << 63); template ostream& operator << (ostream& st, const vector& v) { for (const T value : v) { st << value << " "; } return st; } template istream& operator >> (istream& st, vector& v) { for (T& value : v) { st >> value; } return st; } int pow_(const int a, const int b, const int m = INF) { int res = 1; int base = a; for (int i = 0; i < 64; i++) { if (b & (1ll << i))res *= base; res %= m; base = base * base; base %= m; } return res; } inline int gcd(const int a, const int b) { return (b == 0 ? a : gcd(b, a % b)); } inline int lcm(const int a, const int b) { return a * b / gcd(a, b); } // class nCk { public: const int m; const int MAXIMUM = 1000000; vector fac, facinv, inv; nCk(int m_); ~nCk(); int com(int n, int k)const; }; nCk::nCk(int m_):m(m_) { fac.resize(MAXIMUM + 3); facinv.resize(MAXIMUM + 3); inv.resize(MAXIMUM + 3); fac[0] = fac[1] = 1; facinv[0] = facinv[1] = 1; inv[1] = 1; for (int i = 2; i < MAXIMUM + 2; i++) { fac[i] = fac[i - 1] * i % m; inv[i] = m - inv[m % i] * (m / i) % m; facinv[i] = facinv[i - 1] * inv[i] % m; } } nCk::~nCk(){} int nCk::com(int n, int k)const { if (n < k)return 0; assert(!(n < 0 || k < 0)); return fac[n] * (facinv[k] * facinv[n - k] % m) % m; } template vector press(const vector& arr) { vector X = arr; sort(X.begin(), X.end()); X.erase(unique(X.begin(), X.end()), X.end()); vector ans(arr.size()); for (int i = 0; i < arr.size(); i++) { ans[i] = lower_bound(X.begin(), X.end(), arr[i]) - X.begin(); } return ans; } class LCA { public: vector> parent; vector dist; vector> G; LCA(const vector>& gr) { init(gr); } void dfs(long long v, long long p, long long d) { parent[0][v] = p; dist[v] = d; for (long long next : G[v]) { if (next == p)continue; dfs(next, v, d + 1); } return; } void init(const vector>& gr) { G = gr; parent.assign(33, vector(G.size(), -1LL)); dist.assign(G.size(), -1LL); dfs(0LL, -1LL, 0LL); for (int i = 0; i < 32; i++) { for (int j = 0; j < G.size(); j++) { if (parent[i][j] < 0LL) { parent[i + 1][j] = -1LL; } else { parent[i + 1][j] = parent[i][parent[i][j]]; } } } return; } long long lca(long long u, long long v) { if (u == -1 and v == -1)return -1; else if (u == -1)return v; else if (v == -1)return u; if (dist[u] < dist[v])swap(u, v); long long between = dist[u] - dist[v]; for (int i = 0; i < 33; i++) { if (between & (1LL << i)) { u = parent[i][u]; } } if (u == v)return u; for (int i = 32; i >= 0; i--) { if (parent[i][u] != parent[i][v]) { u = parent[i][u]; v = parent[i][v]; } } assert(parent[0][u] == parent[0][v]); return parent[0][u]; } long long get_dist(long long u, long long v) { return dist[u] + dist[v] - 2 * dist[lca(u, v)]; } bool on_path(long long u, long long v, long long a) { return get_dist(u, v) == get_dist(u, a) + get_dist(v, a); } }; // class Solver { public: int T; Solver() :T(1) {} ~Solver(){} void ios()const; void multi(); void solve() const; void sp(int x)const; void ft()const; // // }; void Solver::ios() const { cin.tie(nullptr); ios_base::sync_with_stdio(false); return; } void Solver::multi() { cin >> T; return; } void Solver::sp(const int x)const { cout << fixed << setprecision(x) << endl; return; } void Solver::ft() const { } void Solver::solve() const { int L, R; cin >> L >> R; dsu d(R + 1); int cnt = 0; for (int e = L; e <= R; e++) { for (int f = e * 2; f <= R; f += e) { if (!d.same(e, f)) { d.merge(e, f); cnt++; } } } cout << (R - L - cnt) << endl; } signed main() { Solver solver; solver.ios(); //solver.ft(); //solver.multi(); //solver.sp(); for (int i = 0; i < solver.T; i++) solver.solve(); return 0; } /* * わらびのコードこーどすぺーす (σ・∀・)σゲッツ!! */