/** * author: shu8Cream * created: 27.08.2021 21:19:26 **/ #include using namespace std; #define rep(i,n) for (int i=0; i<(n); i++) #define rrep(i,n) for (int i=(n-1); i>=0; i--) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() using ll = long long; using P = pair; using vi = vector; using vvi = vector; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } struct Sieve{ int n; vector f,primes; Sieve(int n=1):n(n+1),f(n+1){ f[0] = f[1] = -1; for(ll i=2; i<=n; ++i){ if(f[i]) continue; primes.push_back(i); f[i]=i; for(ll j=i*i; j<=n; j+=i){ if(!f[j]) f[j]=i; } } } bool isPrime(int x){ return f[x]==x;} vector factorList(int x){ vector res; while(x!=1){ res.push_back(f[x]); x/=f[x]; } return res; } vector

factor(int x){ vector fl = factorList(x); if(fl.size()==0) return {}; vector

res(1,P(fl[0], 0)); for(int p : fl){ if(res.back().first == p){ res.back().second++; }else{ res.emplace_back(p,1); } } return res; } vector prime(){ return primes; } }; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); Sieve sieve(15001000); ll l,r; cin >> l >> r; ll ans = 0; for(int i=l+1; i<=r; i++){ if(sieve.isPrime(i+i-1)) ans++; if(sieve.isPrime(i)) ans++; } if(sieve.isPrime(l))ans++; cout << ans << endl; }