#include <bits/stdc++.h>
using namespace std;
const int MAXN = 300000000 + 10;
int L, R;
bitset<MAXN> isp;
inline void isp_cal(int BOUND) {
  isp.set();
  for (int i = 3; i * i <= BOUND; i += 2) {
    if (isp.test(i)) {
      for (int j = i * i; j <= BOUND; j += (i << 1)) {
        isp.reset(j);
      }
    }
  }
}
inline void solve() {
  isp_cal(R);
  int ans = 0;
  if (L <= 2 && 2 <= R) {
    ++ans;
  }
  while ((L & 3) != 1) ++L;
  for (int i = max(5, L); i <= R; i += 4) {
    if (isp.test(i)) {
      ++ans;
    }
  }
  printf("%d\n", ans);
}
int main() {
  scanf("%d%d", &L, &R);
  solve();
  return 0;
}
