#include <bits/stdc++.h>
using namespace std;
long long ans = 0;
long long l, r;
void find_primes(long long n) {
  vector<bool> notprime((n + 1) / 2);
  notprime[0] = true;
  for (long long i = 3; i <= n; i += 2) {
    if (!notprime[i / 2]) {
      if (i >= l && i <= r && i % 4 == 1) ans++;
      if (i * i <= n)
        for (long long j = 3 * i; j <= n; j += 2 * i) notprime[j / 2] = true;
    }
  }
}
int32_t main() {
  cin >> l >> r;
  if (2 >= l && 2 <= r) ans++;
  find_primes(r);
  cout << ans;
}
