#include <bits/stdc++.h>
using namespace std;
const int maxn = 300000001;
int l, r;
bitset<maxn> prime;
int main() {
  cin >> l >> r;
  prime.set();
  prime[0] = prime[1] = false;
  for (int i = 3; i * i <= r; i += 2)
    if (prime[i])
      for (int j = i * i; j <= r; j += i << 1) prime[j] = false;
  int ret = (l <= 2 && 2 <= r);
  while (l % 4 != 1) ++l;
  for (int i = l; i <= r; i += 4)
    if (prime[i]) ret++;
  cout << ret << endl;
  return 0;
}
