#include <bits/stdc++.h>
namespace TNT {
const int MAXN = 3e8 + 10;
const int prime_ = 2e7 + 10;
std::bitset<MAXN> mindiv;
int prime[prime_], tot, ans = 0;
inline void ES(int l, int r) {
  for (register int i = 2; i <= r; i++) {
    if (!mindiv[i]) {
      prime[++tot] = i;
      if (l <= i && (!((i - 1) % 4))) ++ans;
    }
    for (register int j = 1; j <= tot && prime[j] * i <= r; j++) {
      mindiv[i * prime[j]] = 1;
      if (!(i % prime[j])) break;
    }
  }
  if (l <= 2 && r >= 2) ++ans;
  printf("%d\n", ans);
}
inline void main() {
  int l, r;
  scanf("%d%d", &l, &r);
  ES(l, r);
  return;
}
}  // namespace TNT
int main() {
  TNT::main();
  return 0;
}
