#include #define rep(i, n) for (int i = 0; i < (n); ++i) using std::cin; using std::cout; using std::set; using std::vector; using ll = long long; // linear sieve vector ps, pf; void sieve(int mx) { pf.resize(mx + 1); rep(i, mx + 1) pf[i] = i; for (int i = 2; i <= mx; ++i) { if (pf[i] == i) ps.push_back(i); for (int j = 0; j < ps.size() and ps[j] <= pf[i]; ++j) { int x = ps[j] * i; if (x > mx) break; pf[x] = ps[j]; } } } int main() { const int MX = 2000005; sieve(MX); set s; for (int p : ps) s.insert(p); ll l, r; cin >> l >> r; int ans = 0; for (int i = l; i <= r; ++i) { if (s.count(i)) ++ans; int x = 2 * i + 1; if (s.count(x)) ++ans; } cout << ans << '\n'; return 0; }