#include using namespace std; #include using namespace atcoder; #define ll long long #define rep(i, n) for (int i = 0; i < (n); i++) #define P pair #define LP pair #define fi first #define se second #define pb push_back #define eb emplace_back #define all(s) s.begin(), s.end() #define rall(s) s.rbegin(), s.rend() template void chmax(T& a, T b) { a = max(a, b); }; template void chmin(T& a, T b) { a = min(a, b); }; int main() { int l, r; cin >> l >> r; vector prime(2*r+1, true); prime[1] = false; for (int i = 2; i <= 2*r; i++) { if (prime[i]) { for (int j = i*2; j <= 2*r; j += i) prime[j] = false; } } int ans = 0; for (int i = l; i <= r; i++) { if (prime[i]) ans++; } for (int i = l; i < r; i++) { if (prime[2*i+1]) ans++; } cout << ans << endl; return 0; }