#include <bits/stdc++.h>
using namespace std;
int L, R;
bitset<300000001> prim;
void precalc() {
  prim.set();
  for (int i = 3; i * i <= R; i += 2)
    if (prim[i])
      for (int j = i * i; j <= R; j += (i << 1)) prim[j] = false;
}
int main() {
  cin >> L >> R;
  precalc();
  int sol = (L <= 2 && 2 <= R);
  for (int i = 5; i <= R; i += 4)
    if (i >= L && prim[i]) ++sol;
  cout << sol;
  return 0;
}
