#include <bits/stdc++.h>
using namespace std;
const int block_size = sizeof(uint64_t) * 8;
const uint64_t one = 1;
const size_t max_size = 3 * 100000000 + 1;
uint64_t pr[max_size / block_size + 1];
int main(void) {
  int l, r;
  cin >> l >> r;
  for (int i = 3; i * i <= r; i += 2) {
    if (!(pr[i / block_size] & (one << (i % block_size)))) {
      for (int j = i * i; j <= r; j += 2 * i)
        (pr[j / block_size] |= (one << (j % block_size)));
    }
  }
  int ans = 2 >= l && 2 <= r;
  int a = max(1, l / 4), b = r / 4;
  for (int i = a; i <= b; ++i) {
    int v = 4 * i + 1;
    if (v >= l && v <= r && !(pr[v / block_size] & (one << (v % block_size))))
      ++ans;
  }
  cout << ans << endl;
}
