#include <bits/stdc++.h>
using namespace std;
int ans = 0;
int prime[20000010], l, r, cnt;
bitset<300000002> is;
inline void Euler_shai(int l, int r) {
  is[0] = is[1] = 1;
  for (register int i = 2; i <= r; i++) {
    if (is[i] == 0) prime[++cnt] = i;
    for (register int j = 1; j <= cnt && i * prime[j] <= r; j++) {
      is[i * prime[j]] = 1;
      if (i % prime[j] == 0) break;
    }
  }
}
int main() {
  scanf("%d%d", &l, &r);
  Euler_shai(l, r);
  for (register int i = 5; i <= r; i += 4) {
    if (i >= l && is[i] == 0) ans++;
  }
  if (l <= 2 && r >= 2) ans += 1;
  printf("%d\n", ans);
  return 0;
}
