#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e7 + 5;
const int maxm = 3e8 + 5;
int l, r, cnt = 0;
int ans = 0, pri[maxn];
bitset<maxm> flag;
int main() {
  flag.reset();
  scanf("%d%d", &l, &r);
  if (l <= 2 && 2 <= r) ans = 1;
  for (register int i = 2; i <= r; i++) {
    if (!flag[i]) pri[++cnt] = i;
    for (register int j = 1; j <= cnt && i * pri[j] <= r; j++) {
      flag[pri[j] * i] = true;
      if (i % pri[j] == 0) break;
    }
  }
  if (!cnt || pri[cnt] < l) {
    puts("0");
    return 0;
  }
  int pos = lower_bound(pri + 1, pri + cnt, l) - pri;
  for (register int i = pos; pri[i] <= r && i <= cnt; i++) {
    if ((pri[i] - 1) % 4 == 0) ans++;
  }
  printf("%d\n", ans);
  return 0;
}
