#include <bits/stdc++.h>
using namespace std;
int l, r;
bitset<300000010> isp;
int pri[20000010], c1;
inline void shai() {
  int n = r;
  isp[1] = 1;
  for (int i = 2; i <= n; ++i) {
    if (!isp[i]) pri[++c1] = i;
    for (int j = 1; j <= c1 && i * pri[j] <= n; ++j) {
      isp[i * pri[j]] = 1;
      if (i % pri[j] == 0) break;
    }
  }
}
int ans;
int main() {
  cin >> l >> r;
  shai();
  if (l <= 2 && 2 <= r) ++ans;
  for (int i = l; i <= r; ++i)
    if (!isp[i] && (i & 3) == 1) ++ans;
  cout << ans << endl;
  return 0;
}
