#include <iostream> #include <vector> #include <set> #include <algorithm> #include <math.h> #include <string.h> #include <map> #include <numeric> #include <random> #include <queue> #include <deque> #include <tuple> #include <iomanip> #include <iterator> #include <functional> using namespace std; typedef long long ll; const int INF = (1 << 30) - 1; const ll INFLL= (1LL << 61) - 1; const int MOD = 1000000007; #define ALL(a) (a).begin(),(a).end() #define rALL(a) (a).rbegin(),(a).rend() #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) struct UnionFind { vector<int> par; UnionFind(int n) : par(n, -1) { } void init(int n) { par.assign(n, -1); } int root(int x) { if (par[x] < 0) return x; else return par[x] = root(par[x]); } bool issame(int x, int y) { return root(x) == root(y); } bool merge(int x, int y) { x = root(x); y = root(y); if (x == y) return false; if (par[x] > par[y]) swap(x, y); par[x] += par[y]; par[y] = x; return true; } int size(int x) { return -par[root(x)]; } }; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); ll L,R;cin>>L>>R; vector<bool>ok(R+1, false); UnionFind uf(R+1); for(ll i=L; i<=R; i++){ for(ll j=2; i*j<=R; j++){ uf.merge(i,i*j); } } int ans=0; FOR(i,L,R+1){ if(i==uf.root(i)){ ans++; } } cout<<ans-1<<endl; }