#include <bits/stdc++.h>
using namespace std;
int l, r, C = 15000, k, answer = 0, primes[20000];
bool IsPr[20000], pr[20000];
void up(int x) {
  if (x >= l && x <= r && ((x - 1) % 4 == 0 || x == 2)) ++answer;
};
int main() {
  scanf("%d%d", &l, &r);
  if (l > r) l ^= r ^= l ^= r;
  int Sqrt = sqrtl(r);
  for (int i = 2; i <= Sqrt; i++)
    if (!IsPr[i]) {
      primes[k++] = i;
      for (int j = 2 * i; j <= Sqrt; j += i) IsPr[j] = true;
    };
  for (int i = 0; i <= r / C; i++) {
    memset(pr, false, sizeof(pr));
    if (i == 0) pr[0] = pr[1] = true;
    int start = i * C;
    for (int j = 0; j < k; j++) {
      int start_x = (start + primes[j] - 1) / primes[j];
      int k = max(2, start_x) * primes[j] - start;
      for (; k < C; k += primes[j]) pr[k] = true;
    };
    for (int j = 0; j < C; j++)
      if (!pr[j]) up(j + start);
  };
  printf("%d\n", answer);
};
