#include <bits/stdc++.h>
std::bitset<300000005> prime;
int l, r, pri[20000005];
int main(void) {
  register int cnt = 0;
  scanf("%d %d", &l, &r);
  for (register int i = 2; i <= r; i++) {
    if (!prime[i]) pri[cnt++] = i;
    for (register int j = 0, end = r / i; j < cnt && pri[j] <= end; j++) {
      prime[i * pri[j]] = 1;
      if (i % pri[j] == 0) break;
    }
  }
  register int ans = l <= 2 && 2 <= r;
  for (register int i = 0; i < cnt; i++) {
    if (pri[i] > r) break;
    if (pri[i] >= l && pri[i] % 4 == 1) ans++;
  }
  printf("%d", ans);
  return 0;
}
