#include using namespace std; // #include // using namespace atcoder; // using mint = modint1000000007; // using mint2 = modint998244353; typedef int64_t Int; #define all(x) (x).begin(), (x).end() const double EPS = 1e-10; const Int INF = 1e18; const int inf = 1e9; const Int mod = 1e9+7; //const Int mod = 998244353; typedef struct { int64_t to, weight; } edge; Int dx[] = {0, 1, 0, -1, -1, 1, -1, 1}; Int dy[] = {1, 0, -1, 0, -1, -1, 1, 1}; template istream &operator>>(istream &is, vector &v) { for (auto &e : v) { is >> e; } return is; } bool print_space_enable = false; void print() { std::cout << '\n'; print_space_enable = false; } template void print(Head&& head, Tail&&... tail) { if (print_space_enable) std::cout << " "; std::cout << fixed << setprecision(15) << head; print_space_enable = true; print(std::forward(tail)...); } template void print(vector v) { for (size_t i = 0; i < v.size(); i++) { if (i > 0) std::cout << " "; std::cout << v[i]; } std::cout << '\n'; } template vector make_vec(size_t n, T val) { return vector(n, val); } template auto make_vec(size_t n, Ts... ts) { return vector(n, make_vec(ts...)); } bool is_overflow(Int a, Int b) { return a > INF / b; } void solve() { Int l, r; cin >> l >> r; vector prime(2 * r + 1, true); prime[0] = prime[1] = false; for (Int i = 2; i <= 2 * r; i++) { if (prime[i]) { for (Int j = 2; i * j <= 2 * r; j++) { prime[i * j] = false; } } } Int res = 0; for (Int i = l; i <= r; i++) { if (prime[i]) { res++; } } for (Int i = l; i < r; i++) { if (prime[i + i + 1]) { res++; } } print(res); } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); solve(); //Int _t; cin >> _t; while (_t--) solve(); return 0; }