#include <bits/stdc++.h>
std::bitset<300000005> f;
int l, r, i, j, ans;
int main() {
  scanf("%d%d", &l, &r);
  for (i = 3; i * i <= r; i += 2)
    if (!f[i])
      for (j = i * i; j <= r; j += (i << 1)) f[j] = 1;
  for (i = 5; i <= r; i += 4)
    if (!f[i] && i >= l) ans++;
  printf("%d\n", ans + (2 >= l && 2 <= r));
  return 0;
}
