#include using namespace std; using i64 = long long; #define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++) #define all(x) x.begin(),x.end() template static inline std::vector ndvec(size_t&& n, T val) noexcept { return std::vector(n, std::forward(val)); } template static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept { return std::vector(tail)...))>(n, ndvec(std::forward(tail)...)); } template struct chain { Cond cond; chain(Cond cond) : cond(cond) {} bool operator()(T& a, const T& b) const { if(cond(a, b)) { a = b; return true; } return false; } }; template chain make_chain(Cond cond) { return chain(cond); } #include #include struct union_find { std::vector par; union_find(int N): par(N, -1) {} int root(int x) { return par[x] < 0 ? x : par[x] = root(par[x]); } std::tuple unite(int x, int y) { x = root(x); y = root(y); if(x == y) return { -1, -1 }; if(par[x] > par[y]) std::swap(x, y); par[x] += par[y]; par[y] = x; return { x, y }; } int size(int x) { return -par[root(x)]; } }; int main() { i64 L, R; cin >> L >> R; union_find uf(R + 1); std::vector cost(R + 1, 1); for(int i = R + 1; i --> L;) { for(int j = i + i; j < R + 1; j += i) { uf.unite(i, j); } } i64 ans = 0; rep(i,L + 1, R + 1) { int r = uf.root(i); ans += cost[r]; cost[r] = 0; } std::cout << ans - 1 << '\n'; }