#include <bits/stdc++.h>
using namespace std;
int ans, l, r, cnt;
int prime[20000001];
bitset<300000005> is;
void getpri(int r) {
  is[0] = is[1] = 1;
  for (int i = 2; i <= r; i++) {
    if (is[i] == 0) {
      prime[++cnt] = i;
    }
    for (int j = 1; j <= cnt && i * prime[j] <= r; j++) {
      is[i * prime[j]] = 1;
      if (i % prime[j] == 0) break;
    }
  }
}
int main() {
  cin >> l >> r;
  getpri(r);
  for (int i = 5; i <= r; i += 4) {
    if (i >= l && is[i] == 0) {
      ans++;
    }
  }
  if (l <= 2 && r >= 2) ans++;
  cout << ans << endl;
  return 0;
}
