#include <bits/stdc++.h>
using namespace std;
bitset<300000010> f;
int cnt, l, r, su[20000010], ans;
inline int read() {
  int x = 0, ff = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') ff = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 3) + (x << 1) + ch - 48;
    ch = getchar();
  }
  return x * ff;
}
inline void write(int x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
signed main() {
  l = read(), r = read();
  for (register int i = 2; i <= r; i++) {
    if (!f[i]) su[cnt++] = i;
    for (register int j = 0; j < cnt && su[j] * i <= r; j++) {
      f[su[j] * i] = 1;
      if (i % su[j] == 0) break;
    }
  }
  if (l <= 2 && r >= 2) ans++;
  for (register int i = 1; i <= cnt; i++) {
    if (su[i] < l) continue;
    if (su[i] % 4 == 1) ans++;
  }
  write(ans);
}
