#include <bits/stdc++.h>
using namespace std;
const int maxn = 3 * 1e8 + 20;
bitset<maxn> p;
int cnt;
int l, r, ans;
inline void isprime(int maxsize) {
  p.set();
  for (int i = 3; i * i <= maxsize; i += 2) {
    if (p[i]) {
      for (int j = i * i; j <= maxsize; j += i << 1) {
        p[j] = false;
      }
    }
  }
  if (l <= 2 && 2 <= r) ans = 1;
  for (int i = 5; i <= r; i += 4) {
    if (i >= l && p[i]) ans++;
  }
}
int main() {
  scanf("%d%d", &l, &r);
  isprime(r);
  printf("%d\n", ans);
  return 0;
}
