#include #include using namespace std; using namespace atcoder; typedef int64_t lint; #define rep(i, n) for(int i=0; i; using vvi = vector>; template inline void vin(vector& v) { rep(i, v.size()) cin >> v.at(i); } template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } template inline void drop(T x) { cout << x << endl; exit(0); } template void vout(vector v) { rep(i, v.size()) { cout << v.at(i) << ' '; } cout << endl; } constexpr lint LINF = LLONG_MAX/2; struct Sieve { int n; vector p; Sieve(int n=1):n(n), p(n+1) { p.at(0) = -1, p.at(1) = -1; for(lint i=2; i<=sqrt(n)+1; i++) { if(!p.at(i)) { p.at(i) = i; for(lint j=i*i; j<=n; j+=i) { if (!p.at(j)) p.at(j) = i; } } } } bool isPrime(int x) { return (p.at(x) == x || p.at(x) == 0);} vector factorList(int x) { vector v; while (x != 1) { v.push_back(p.at(x)); x /= p.at(x); } return v; } vector factor(int x) { vector v; while (x != 1) { int t = p.at(x); v.push_back(t); while (x % t == 0) x /= t; } return v; } }; int main() { lint L, R; cin >> L >> R; lint a=0, b=0, c=0, x, y, z; Sieve S(R*2+1); repx(i, L, R+1) { if (S.isPrime(i)) a++; if (S.isPrime(i*2+1) && i != R) a++; } std::cout << a << '\n'; }