#include <bits/stdc++.h>
using namespace std;
const int N = 300000005;
bitset<N> lp;
int l, r;
void seive() {
  int i, j, ans = 0;
  for (i = 2; 1LL * i * i <= r; i++) {
    if (!lp[i]) {
      for (j = i * i; j <= r; j += i) lp[j] = true;
    }
  }
  for (i = 5; i <= r; i += 4) {
    if (!lp[i] && i >= l) ans++;
  }
  if (l <= 2 && r >= 2) ans++;
  printf("%d\n", ans);
}
int main() {
  cin >> l >> r;
  seive();
}
