#include <bits/stdc++.h>
using namespace std;
int ans = 0;
int pri[20000005], l, r, cnt;
bitset<300000005> vis;
inline int read() {
  int x = 0;
  int f = 1;
  char ch;
  do {
    ch = getchar();
    if (ch == '-') f = -1;
  } while (ch > '9' || ch < '0');
  do {
    x = x * 10 + ch - '0';
    ch = getchar();
  } while (ch >= '0' && ch <= '9');
  return x * f;
}
inline void init(int l, int r) {
  vis[0] = vis[1] = 1;
  pri[++cnt] = 2;
  vis[4] = 1;
  for (register int i = 3; i <= r; i += 2) {
    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() {
  l = read();
  r = read();
  init(l, r);
  for (register int i = 5; i <= r; i += 4)
    if (i >= l && vis[i] == 0) ++ans;
  if (l <= 2 && r >= 2) ans += 1;
  printf("%d\n", ans);
  return 0;
}
