#include <bits/stdc++.h>
unsigned BIT[10000000], ans = 0;
int p[100000 + 1] = {0}, l, r;
void sieve() {
  memset(BIT, 0, sizeof(BIT));
  for (int i = 3; i <= r; i += 2) {
    if (!(BIT[(i) >> 5] & (1 << ((i)&31)))) {
      if (p[0] < 100000) p[++p[0]] = i;
      if (i % 4 == 1 && i >= l) ans++;
    }
    for (int j = 1; p[j] <= r / i; j++) {
      do {
        BIT[(p[j] * i) >> 5] |= (1 << ((p[j] * i) & 31));
      } while (0);
      if (i % p[j] == 0) break;
    }
  }
  if (2 >= l && 2 <= r) ans++;
}
int main(int argc, char *argv[]) {
  scanf("%d%d", &l, &r);
  sieve();
  printf("%d\n", ans);
  return EXIT_SUCCESS;
}
