#include <bits/stdc++.h>
using namespace std;
int main() {
  clock_t s = clock();
  int l, r;
  cin >> l >> r;
  int ans = 0;
  static unsigned int isPrime[300000000 / 32 + 1];
  int sqrtN = sqrt(1.0 * r) + 1;
  int N = r;
  int n;
  for (int z = 1; z <= 5; z += 4) {
    for (int y = z; y <= sqrtN; y += 6) {
      for (int x = 1; x <= sqrtN && (n = 4 * x * x + y * y) <= N; ++x)
        isPrime[n >> 5] ^= (1 << (n & 31));
      for (int x = y + 1; x <= sqrtN && (n = 3 * x * x - y * y) <= N; x += 2)
        isPrime[n >> 5] ^= (1 << (n & 31));
    }
  }
  for (int z = 2; z <= 4; z += 2) {
    for (int y = z; y <= sqrtN; y += 6) {
      for (int x = 1; x <= sqrtN && (n = 3 * x * x + y * y) <= N; x += 2)
        isPrime[n >> 5] ^= (1 << (n & 31));
      for (int x = y + 1; x <= sqrtN && (n = 3 * x * x - y * y) <= N; x += 2)
        isPrime[n >> 5] ^= (1 << (n & 31));
    }
  }
  bitset<32> tmp(isPrime[0]);
  for (int y = 3; y <= sqrtN; y += 6) {
    for (int z = 1; z <= 2; ++z) {
      for (int x = z; x <= sqrtN && (n = 4 * x * x + y * y) <= N; x += 3)
        isPrime[n >> 5] ^= (1 << (n & 31));
    }
  }
  for (int n = 5; n <= sqrtN; ++n)
    if (isPrime[n >> 5] & (1 << (n & 31)))
      for (int k = n * n; k <= N; k += n * n)
        isPrime[k >> 5] &= ~(1 << (k & 31));
  isPrime[0] |= 3 << 2;
  if (l <= 2 && r >= 2) ans++;
  l = (5 - l % 4) % 4 + l;
  for (int i = l; i <= r; i += 4) {
    if (isPrime[i >> 5] & (1 << (i & 31))) ans++;
  }
  cout << ans << endl;
  return 0;
}
