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