#include <bits/stdc++.h>
using namespace std;
bitset<300000005> pr;
int uke[20000005];
int anti_uke(int l, int r) {
  int ans = 0;
  for (register int i = 5; i <= r; i += 4) {
    if (i >= l && pr[i] == 0) ++ans;
  }
  if (l <= 2 && r >= 2) ++ans;
  return ans;
}
int main() {
  int l, r;
  scanf("%d %d", &l, &r);
  pr[0] = pr[1] = 1;
  int cnt = 0;
  for (register int i = 2; i <= r; i++) {
    if (pr[i] == 0) uke[++cnt] = i;
    for (register int j = 1; j <= cnt && i * uke[j] <= r; j++) {
      pr[i * uke[j]] = 1;
      if (i % uke[j] == 0) break;
    }
  }
  printf("%d\n", anti_uke(l, r));
  return 0;
}
