#include <bits/stdc++.h>
using namespace std;
const int MAX_BUF_SIZE = 16384;
char BUFOR[MAX_BUF_SIZE];
int BUF_SIZE, BUF_POS;
char ZZZ;
const int MXN = 510;
const int C = 262144;
const int INF = 1000000001;
const int Q = 3 * 100000000 + 1;
bitset<Q> V;
void test() {
  int a, n;
  scanf("%d %d", &a, &n);
  for (int i = 3; i * i <= n; i += 2)
    if (!V[i])
      for (int j = i * i; j <= n; j += i << 1) V[j] = 1;
  V[1] = 1;
  int b = a, res = 0;
  while ((b % 4) != 1) b++;
  for (int i = b; i <= n; i += 4)
    if (!V[i]) res++;
  if (a <= 2 && 2 <= n) res++;
  printf("%d\n", res);
}
int main() {
  int te = 1;
  while (te--) test();
}
