#include <bits/stdc++.h>
using namespace std;
const int maxn = 300000010;
bitset<maxn> pri;
int main() {
  pri.set();
  int l, r;
  scanf("%d%d", &l, &r);
  for (int i = 3, j; (j = i * i) <= r; i += 2)
    if (pri[i])
      for (; j <= r; j += i + i) pri[j] = false;
  int ans = 0;
  for (int i = 5; i <= r; i += 4)
    if (i >= l && pri[i]) ans++;
  if (l <= 2 && r >= 2) ans++;
  printf("%d\n", ans);
  return 0;
}
