#include <bits/stdc++.h>
using namespace std;
const int maxr = 1e4 * 2;
bool is[maxr];
bool u[maxr * maxr / 4 + 200];
vector<long long> v;
long long l, r;
int main() {
  for (int i = 2; i < maxr; ++i) is[i] = true;
  for (int i = 2; i < maxr; ++i)
    if (is[i]) {
      v.push_back((long long)i);
      for (int j = i; j * i < maxr; ++j) is[j * i] = false;
    }
  cin >> l >> r;
  u[0] = true;
  for (int i = 1; i < (int)v.size(); ++i)
    for (long long j = v[i]; j * v[i] <= r; j += 1 << 2)
      u[v[i] * j >> 2] = true;
  int ans = (l <= 2 && r >= 2), ri = (r - 1) >> 2;
  for (int i = (l + 2) >> 2; i <= ri; ++i)
    if (!u[i]) ++ans;
  cout << ans << endl;
  return 0;
}
