#include using namespace std; using ll = long long; vector IsPrime; void Sieve(int max){ if(max + 1 > IsPrime.size()){ IsPrime.assign(max + 1, true); } IsPrime[0] = false; IsPrime[1] = false; for(int i = 2; i * i <= max; i++){ if(IsPrime[i]){ for(int j = 2; i * j <= max; j++){ IsPrime[i * j] = false; } } } return; } int main(){ int L, R; cin >> L >> R; ll ans = 0; Sieve(3 * R); for(int a = L; a <= R; a++){ if(IsPrime[a])++ans; if(a < R && IsPrime[2 * a + 1])++ans; } cout << ans << endl; }