#include <bits/stdc++.h>
using namespace std;
const int maxn = 300000000;
bool flag[maxn / 4 + 10];
int prime[50000], vs[50000], pl;
void _prime(int n) {
  for (int i = 2; i <= n; i++) {
    if (!vs[i]) prime[pl++] = i;
    for (int j = 0; j < pl && i * prime[j] <= n; j++) {
      vs[i * prime[j]] = 1;
      if (i % prime[j] == 0) break;
    }
  }
}
int initprime(int l, int r) {
  int ans = 0;
  if (l <= 2 && r >= 2) ans++;
  while (l % 4 != 1 || l == 1) l++;
  int sqt = (int)sqrt(0.5 + r);
  _prime(sqt);
  for (int i = 0; i < pl; i++) {
    int g = l / prime[i];
    if (g < 2) g = 2;
    int j = g * prime[i];
    for (; j <= r; j += prime[i]) {
      if (j % 4 == 1) {
        flag[j >> 2] = 1;
      }
    }
  }
  for (int i = l; i <= r; i += 4) {
    if (!flag[i >> 2]) ans++;
  }
  return ans;
}
int main() {
  int l, r;
  scanf("%d%d", &l, &r);
  int ans = initprime(l, r);
  printf("%d\n", ans);
  return 0;
}
