#include <bits/stdc++.h>
using namespace std;
int main() {
  static bitset<size_t(3e8 + 1)> sieve;
  int l, r, count = 0;
  cin >> l >> r;
  sieve.set();
  sieve[0] = sieve[1] = false;
  for (int i = 3; i * i <= r; i += 2)
    if (sieve[i])
      for (int j = i * i; j <= r; j += 2 * i) sieve[j] = false;
  for (int i = 5; i <= r; i += 4)
    if (l <= i && sieve[i]) ++count;
  cout << (count + (l <= 2 && 2 <= r)) << endl;
}
