#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e8 + 10;
bitset<maxn> prime;
int main() {
  int l, r, ans = 0;
  cin >> l >> r;
  for (int i = 3; i * i <= r; i += 2) {
    if (!prime[i]) {
      for (int j = i * i; j <= r; j += (2 * i)) prime[j] = true;
    }
  }
  if (l <= 2 && r >= 2) ans = 1;
  int tmp = l;
  l = (l / 4) * 4 + 1;
  if (l < tmp) l += 4;
  if (l < 5) l = 5;
  for (int i = l; i <= r; i += 4) {
    if (i >= l && !prime[i]) ans++;
  }
  cout << ans;
}
