#include <bits/stdc++.h>
using namespace std;
void solve();
int main() {
  solve();
  return 0;
}
const int size = 300 * 1000 * 1000 + 1;
bitset<size> p;
int L, R;
void calcPrimes() {
  p.set();
  for (int i = 3; i * i <= R; i += 2)
    if (p[i])
      for (int k = i * i; k <= R; k += (i << 1)) p[k] = false;
}
void solve() {
  scanf("%d%d", &L, &R);
  calcPrimes();
  int ans = 0;
  if (L <= 2 && 2 <= R) ans++;
  while (L == 1 || (L & 3) != 1) L++;
  for (int i = L; i <= R; i += 4)
    if (p[i]) ans++;
  printf("%d\n", ans);
}
