#include <bits/stdc++.h>
using namespace std;
inline void read(int& x) {
  x = 0;
  int f = 1;
  char chr = getchar();
  while (chr < '0' || chr > '9') {
    if (chr == '-') f = -1;
    chr = getchar();
  }
  while (chr >= '0' && chr <= '9') {
    x = x * 10 + (chr - '0');
    chr = getchar();
  }
  x = x * f;
  return;
}
inline void print(int x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) print(x / 10);
  putchar(x % 10 + '0');
  return;
}
int pri[20000005], cnt, ans;
bitset<300000005> vis;
inline void make_prime_list(register int l, register int r) {
  vis[1] = vis[0] = 1;
  for (register int i = 2; i <= r; i++) {
    if (vis[i] == 0) pri[++cnt] = i;
    for (register int j = 1; j <= cnt && i * pri[j] <= r; j++) {
      vis[i * pri[j]] = 1;
      if (i % pri[j] == 0) break;
    }
  }
}
int main() {
  int l, r;
  while (scanf("%d%d", &l, &r) != EOF) {
    cnt = 0, ans = 0;
    make_prime_list(l, r);
    for (register int i = 5; i <= r; i += 4)
      if (vis[i] == 0 && i >= l) ++ans;
    if (l <= 2 && r >= 2) ans += 1;
    print(ans), puts("");
  }
  return 0;
}
