#include <bits/stdc++.h>
using namespace std;
int l, r, cnt;
const int maxn = (int)3e8 + 10;
bitset<maxn> bs;
int pri[(int)2e7];
void make_prime(int x) {
  for (int i = 2; i <= x; ++i) {
    if (!bs.test(i)) pri[++cnt] = i;
    for (int j = 1; i * pri[j] <= x && j <= cnt; ++j) {
      bs[i * pri[j]] = 1;
      if (i % pri[j] == 0) break;
    }
  }
}
int main() {
  scanf("%d%d", &l, &r);
  bs.reset();
  make_prime(r);
  int ans = l <= 2 && r >= 2;
  for (int i = 3; pri[i] <= r && i <= cnt; ++i)
    if (pri[i] % 4 == 1 && pri[i] >= l) ans++;
  cout << ans;
  return 0;
}
