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