#include <bits/stdc++.h>
using namespace std;
const int MAX = 3 * 100000000 + 10;
unsigned long prime[MAX / 32 + 1];
unsigned long answer = 0;
inline bool isPrime(unsigned long a) {
  if (a != 2 && a % 2 == 0) return false;
  return (prime[a / 32] & (1 << (a % 32))) == 0;
}
inline void setNotPrime(unsigned long a) { prime[a / 32] |= (1 << (a % 32)); }
void findPrimes(unsigned long r) {
  int len = (int)(sqrt((float)r) + 0.5);
  for (int i = 3; i <= len; i += 2) {
    unsigned long flag = (1 << (i % 32));
    if ((prime[i / 32] & flag) == 0) {
      unsigned long t = i * i;
      while (t <= r) {
        prime[t / 32] |= (1 << (t % 32));
        t = t + 2 * i;
      }
    }
  }
}
int main() {
  unsigned long l = 0;
  unsigned long r = 0;
  cin >> l >> r;
  findPrimes(r);
  setNotPrime(1);
  int max_a = (int)(sqrt((float)r) + 0.5);
  int result = 0;
  unsigned long val = 0;
  const int shift[4] = {1, 0, 3, 2};
  if (2 >= l && 2 <= r) result++;
  l = l + shift[l % 4];
  for (unsigned long i = l; i <= r; i += 4) {
    if (isPrime(i)) result++;
  }
  cout << result << endl;
  return 0;
}
