#include <bits/stdc++.h>
using namespace std;
bitset<17500> ISP;
bitset<300000000 / 4 + 10> result;
int prime[17500];
int is_prime() {
  int p = 0;
  ISP[0] = ISP[1] = 1;
  for (int i = 1; i <= 17500; i++)
    if (ISP[i] == 0) {
      prime[p++] = i;
      for (int j = i + i; j <= 17500; j += i) ISP[j] = 1;
    }
  return p - 1;
}
int cnt(int L, int R) {
  int p = is_prime();
  for (int j = 0; j <= p; j++) {
    int x = L / prime[j];
    if (x * prime[j] < L) x++;
    if (x == 1) x++;
    for (int k = x * prime[j]; k <= R; k += prime[j])
      if (k % 4 == 1) result[(k - 1) / 4] = 1;
  }
  int cnt = 0;
  for (int i = L; i <= R; i += 4)
    if (!result[(i - 1) / 4]) cnt++;
  return cnt;
}
int main() {
  is_prime();
  int L, R;
  int ok = 0;
  cin >> L >> R;
  if (L <= 2 && R >= 2) ok = 1;
  while (L % 4 != 1 || L == 1) L++;
  while (R % 4 != 1) R--;
  cout << cnt(L, R) + ok;
  return 0;
}
