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