#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3e8 + 10;
bitset<MAXN> prime;
int main() {
  int l, r, cnt;
  scanf("%d%d", &l, &r);
  prime.set();
  for (int i = 3; i * i <= r; i += 2)
    if (prime[i])
      for (int j = i * i; j <= r; j += 2 * i) prime[j] = false;
  cnt = l <= 2 && r >= 2;
  for (int i = max(5, l / 4 * 4 + 1); i <= r; i += 4)
    if (i >= l && prime[i]) cnt++;
  printf("%d", cnt);
  return 0;
}
