#include #define REP(i, m, n) for(int i = (int)(m); i < (int)(n); ++i) #define rep(i, n) REP(i, 0, n) using namespace std; using ll = long long; using ld = long double; template inline bool chmax(T &a, const U &b) { if(a < b) { a = b; return true; } return false; } template inline bool chmin(T &a, const U &b) { if(a > b) { a = b; return true; } return false; } struct UnionFind { vector data; UnionFind(int n) : data(n, -1) {} int root(int x) { if(data[x] < 0) return x; return data[x] = root(data[x]); } bool unite(int x, int y) { x = root(x), y = root(y); if(x == y) return false; if(data[x] > data[y]) swap(x, y); data[x] += data[y]; data[y] = x; return true; } int same(int x, int y) { return root(x) == root(y); } int size(int x) { return -data[root(x)]; } }; int l, r; int main() { cin.tie(0); ios::sync_with_stdio(false); cin >> l >> r; UnionFind uf(r-l+1); REP(i, l, r+1) { if(uf.root(i-l) != i-l) continue; for(ll j = i*2; j <= r; j += i) { uf.unite(i-l, j-l); } } ll ans = 0; rep(i, r-l+1) if(uf.root(i) == i) ans++; ans--; cout << ans << '\n'; return 0; }