#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; vector prime; void erat(long long N){ prime.resize(N+1, 1); prime[0] = 0; prime[1] = 0; for (long long i=2; i*i<=N; i++){ if (prime[i]){ for (long long j=i*2; j <= N; j+=i){ prime[j] = 0; } } } } int main(){ int L, R, ans=0; cin >> L >> R; erat(3e6); for (int i=L; i<=R; i++){ if (prime[i]) ans++; if (prime[2*i+1] && i+1<=R) ans++; } cout << ans << endl; return 0; }