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