#include <bits/stdc++.h>
using namespace std;
inline int read() {
  char ch = getchar();
  if (!(~ch)) return 0;
  int f = 1;
  while (ch > '9' || ch < '0') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  int x = 0;
  while (ch >= '0' && ch <= '9') {
    x = (x << 3) + (x << 1) + (ch ^ 48);
    ch = getchar();
  }
  return x * f;
}
int pri[20000005];
bitset<300000001> vis;
int main() {
  vis.set();
  int l = read(), r = read(), tot = 0;
  for (register int i = 2; i <= r; ++i) {
    if (vis[i]) pri[++tot] = i;
    for (register int j = 1; j <= tot && i * pri[j] <= r; ++j) {
      vis[i * pri[j]] = 0;
      if (!(i % pri[j])) break;
    }
  }
  int cnt = l <= 2 && r >= 2;
  for (register int i = 1; i <= tot; ++i)
    if (pri[i] >= l) {
      if (!((pri[i] - 1) % 4)) cnt++;
      if (pri[i] > r) break;
    }
  printf("%d\n", cnt);
  return 0;
}
