#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3e8 + 10;
int cnt;
bitset<MAXN> prime;
int main() {
  int r, l;
  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 = 1;
  int a;
  a = max(5, l / 4 * 4 + 1);
  for (int i = a; i <= r; i = i + 4) {
    if (i >= l && prime[i]) cnt++;
  }
  cout << cnt;
  return 0;
}
