#include using namespace std; struct iofast_t { iofast_t() { ios::sync_with_stdio(false); cin.tie(nullptr); } } iofast; struct uns_t {} uns; template auto vec(Element init, Head arg, Args ...args) { if constexpr (sizeof...(Args) == 0) return std::vector(arg, init); else return std::vector(arg, vec(init, args...)); } template auto vec(uns_t, Head arg, Args ...args) { return vec(Element(), arg, args...); } template > T &chmin(T &l, T r, Compare &&f = less()) { return l = min(l, r, f); } template > T &chmax(T &l, T r, Compare &&f = less()) { return l = max(l, r, f); } int main() { int l, r; cin >> l >> r; const int lim = 2 * r; auto is_prime = vec(true, lim + 1); is_prime[0] = is_prime[1] = false; for (int i = 2; i <= lim / i; ++i) { if (!is_prime[i]) { continue; } for (int j = i * i; j <= lim; j += i) { is_prime[j] = false; } } auto check = [&](int64_t a, int64_t b, int64_t p) { return l <= a && a <= b && b <= r && is_prime[p]; }; int ans = 0; for (int i = max(2, l); i <= r; ++i) { ans += check(2 - i, i, i + i - 1); ans += check(i - 1, i, i + i - 1); ans += check(1 - i, i, (i + i - 1) / 2) && (i + i - 1) % 2 == 0; ans += check(i, i, (i + i) / 2); } cout << ans << endl; }