#include <bits/stdc++.h>
using namespace std;
bitset<300000005> isp;
int main() {
  int l, r;
  while (scanf("%d %d", &l, &r) != EOF) {
    int ret = 0, i, j;
    isp.set();
    isp[0] = isp[1] = 0;
    for (i = 3; i * i <= r; i += 2)
      if (isp[i])
        for (j = i * i; j <= r; j += (i << 1)) isp[j] = 0;
    for (i = (((l + 2) >> 2) << 2) + 1; i <= r; i += 4)
      if (isp[i]) ret++;
    ret += (l <= 2 && r >= 2);
    printf("%d\n", ret);
  }
}
