#include using namespace std; #define rep(i,n) for(int i = 0; i < (n);i++) #define sz(x) int(x.size()) typedef long long ll; typedef pair P; struct UnionFind{ vector data; int __size; UnionFind(int sz) { data.assign(sz, -1); __size = sz; } bool unite(int x, int y) { x = find(x), y = find(y); if(x == y) return (false); if(data[x] > data[y]) swap(x, y);//親は負でサイズを保存 __size--; data[x] += data[y]; data[y] = x; return (true); } int find(int k) { if(data[k] < 0) return (k); return (data[k] = find(data[k])); } bool same(int x, int y){ return find(x) == find(y); } int size(int k) { return (-data[find(k)]); } int union_count() { return (__size); } }; int main() { int l, r; cin >> l >> r; int n = r - l + 1; UnionFind uf(n); for (int i = 0; i < n; i++) { int d = i + l; for (ll j = i + d; j < n; j += d) { uf.unite(i, j); } } cout << uf.union_count() - 1 << endl; return 0; }