/** * author: tomo0608 * created: 27.08.2021 21:26:11 **/ #ifdef __LOCAL #define _GLIBCXX_DEBUG #endif #pragma GCC optimize("Ofast") #include using namespace std; #if __has_include() #include using namespace atcoder; #endif typedef long long ll; typedef long double ld; template using V = vector; template using VV = V>; template using VVV = V>; typedef pair pii; typedef pair pll; #define all(x) x.begin(),x.end() #define SUM(v) accumulate(all(v), 0LL) #define MIN(v) *min_element(all(v)) #define MAX(v) *max_element(all(v)) #define lb(c, x) distance((c).begin(), lower_bound(all(c), (x))) #define ub(c, x) distance((c).begin(), upper_bound(all(c), (x))) #define UNIQUE(x) sort(all(x)), x.erase(unique(all(x)), x.end()) template void zip(vector &x) {vector y = x;UNIQUE(y);for(int i = 0; i < x.size(); ++i) { x[i] = lb(y, x[i]); }} #define rep1(a) for(long long i = 0; i < a; i++) #define rep2(i, a) for(long long i = 0; i < a; i++) #define rep3(i, a, b) for(long long i = a; i < b; i++) #define rep4(i, a, b, c) for(long long i = a; i < b; i += c) #define drep1(a) for(long long i = a-1; i >= 0; i--) #define drep2(i, a) for(long long i = a-1; i >= 0; i--) #define drep3(i, a, b) for(long long i = a-1; i >= b; i--) #define drep4(i, a, b, c) for(long long i = a-1; i >= b; i -= c) #define overload4(a, b, c, d, e, ...) e #define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__) #define drep(...) overload4(__VA_ARGS__, drep4, drep3, drep2, drep1)(__VA_ARGS__) templatevoid input(T&... a){(cin >> ... >> a);}; #define INT(...) int __VA_ARGS__; input(__VA_ARGS__) #define LL(...) ll __VA_ARGS__; input(__VA_ARGS__) #define STR(...) string __VA_ARGS__; input(__VA_ARGS__) #define DBL(...) double __VA_ARGS__; input(__VA_ARGS__) void print(){cout << '\n';} templatevoid print(const T& a, const Ts&... b){cout << a; (cout << ... << (cout << ' ', b)); cout << '\n';} void drop(){cout << '\n';exit(0);} templatevoid drop(const T& a, const Ts&... b){cout << a; (cout << ... << (cout << ' ', b)); cout << '\n';exit(0);} template using priority_queue_rev = priority_queue, greater >; template inline bool chmax(T &a, const U &b) { if (a inline bool chmin(T &a, const U &b) { if (a>b) { a=b; return 1; } return 0; } template istream &operator>>(istream &is, pair &p) { is >> p.first >> p.second; return is; } template ostream &operator<<(ostream &os, const pair &p) { os << '(' << p.first << ", " << p.second << ')'; return os; } template istream &operator>>(istream &is, vector &v) { for (auto &e : v) is >> e; return is; } template ostream &operator<<(ostream &os, const vector &v) { for (auto &e : v) os << e << ' '; return os; } template ostream& operator << (ostream& os, set& set_var) {os << "{"; for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {os << *itr;++itr;if(itr != set_var.end()) os << ", ";itr--;}os << "}";return os;} template ostream &operator<<(ostream &os, map &map_var) {os << "{";for(auto itr = map_var.begin(); itr != map_var.end(); itr++) {os << *itr;itr++;if (itr != map_var.end()) os << ", ";itr--;}os << "}";return os;} #ifdef __LOCAL void debug_out(){ cerr << endl;} template < class Head, class... Tail> void debug_out(Head H, Tail... T) { cerr << ' ' << H; debug_out(T...);} #define debug(...) cerr << 'L' << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__) #define dump(x) cerr << 'L' << __LINE__ << " " << #x << " = " << (x) << endl #else #define debug(...) (void(0)) #define dump(x) (void(0)) #endif template inline int count_between(vector &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r) #define mp make_pair #define bit(n, k) ((n >> k) & 1) /*nのk bit目*/ int topbit(signed t) { return t == 0 ? -1 : 31 - __builtin_clz(t); } int topbit(ll t) { return t == 0 ? -1 : 63 - __builtin_clzll(t); } int lowbit(signed a) { return a == 0 ? 32 : __builtin_ctz(a); } int lowbit(ll a) { return a == 0 ? 64 : __builtin_ctzll(a); } template T mypow(T x, ll n){T ret = 1;while(n > 0){if(n & 1)(ret *= x);(x *= x);n >>= 1;}return ret;} #define endl '\n' int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1}; int dy[8] = {0, 1, 0, -1, 1, -1, -1, 1}; // Primality test class Prime { public: const int N; vector min_prime; vector primes; Prime(int size): N(size), min_prime(N+1){ rep(i,N+1)min_prime[i] = i; min_prime[0] = -1; min_prime[1] = -1; for(int i = 2;i<=N;i++){ if(min_prime[i]!=i)continue; primes.push_back(i); int tmp = 2*i; while(tmp <= N){ if(min_prime[tmp]==tmp)min_prime[tmp] = i; tmp += i; } } } bool check(int x){ return min_prime[x] == x;} }; map prime_factorization(ll n){ map res; n = abs(n); assert(n > 1); for(ll i = 2; i * i <= n; i++){ if(n%i == 0){ int num = 0; while(n%i == 0){ num++; n /= i; } res[i] = num; } } if(n != 1)res[n] = 1; return res; } int64_t euler_phi(int64_t n) { int64_t ret = n; for(int64_t i = 2; i * i <= n; i++) { if(n % i == 0) { ret -= ret / i; while(n % i == 0) n /= i; } } if(n > 1) ret -= ret / n; return ret; } void solve(){ INT(l,r); Prime p(2*r+2); ll ans = 0; rep(i,1,2*r+2){ if(!p.check(i))continue; if(l <= i && i <= r)ans++; if(i%2 == 1 && l <= (i-1)/2 && (i+1)/2 <= r)ans++; } print(ans); } int main() { cin.tie(0); ios_base::sync_with_stdio(false); cout << setprecision(20); int codeforces = 1; //cin >> codeforces; while(codeforces--){ solve(); } return 0; }