#include <bits/stdc++.h>
using namespace std;
int r, l, pri[20000005], cnt, tot;
bitset<300000005> flag;
inline void make_prime_list(register int n) {
  for (register int i = 2; i <= n; ++i) {
    if (!flag[i]) pri[++cnt] = i;
    for (register int j = 1; j <= cnt && i * pri[j] <= n; ++j) {
      flag[i * pri[j]] = 1;
      if (i % pri[j] == 0) break;
    }
  }
}
inline void read(register int &x) {
  register int f = 1;
  x = 0;
  register char c = getchar();
  for (; c > '9' || c < '0'; c = getchar())
    if (c == '-') f = -1;
  for (; c >= '0' && c <= '9'; c = getchar())
    x = (x << 3) + (x << 1) + (c ^ 48);
  x *= f;
}
inline void print(register int x) {
  if (x < 0) x = -x, putchar('-');
  if (x > 9) print(x / 10);
  putchar(x % 10 + '0');
}
int main() {
  read(l), read(r);
  if (l <= 2 && r >= 2) ++tot;
  make_prime_list(r);
  for (register int i = 1; i <= cnt; ++i) {
    if (pri[i] < l) continue;
    if (pri[i] % 4 == 1) ++tot;
  }
  print(tot);
}
