#include <bits/stdc++.h>
using namespace std;
int tot, pri[20000007], ans;
bitset<300005005> flag;
void prime(int r) {
  for (register int i = 2; i <= r; ++i) {
    if (!flag[i]) pri[++tot] = i;
    for (register int j = 1; j <= tot && pri[j] * i <= r; ++j) {
      flag[i * pri[j]] = true;
      if (i % pri[j] == 0) break;
    }
  }
}
int l, r;
int main() {
  cin >> l >> r;
  prime(r);
  for (register int i = 1; i <= tot; ++i) {
    if (pri[i] < l) continue;
    if (pri[i] % 4 == 1) ++ans;
  }
  if (l <= 2 && r >= 2) ++ans;
  printf("%d\n", ans);
  return 0;
}
