#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e8 + 5;
int flag[20000], pri[10000], cnt, l, r, ans;
bitset<maxn> vis;
void make_prime(int m) {
  for (int i = 2; i <= m; ++i) {
    if (!flag[i]) pri[++cnt] = i;
    for (int j = 1; j <= cnt && pri[j] <= m / i; ++j) {
      flag[pri[j] * i] = 1;
      if (i % pri[j] == 0) break;
    }
  }
}
int main() {
  scanf("%d%d", &l, &r);
  make_prime((sqrt(r)));
  if (l <= 2 && 2 <= r) ++ans;
  vis.set();
  for (int i = 1; i <= cnt; ++i) {
    int t1 = (l - 1) / pri[i] + 1;
    int t2 = r / pri[i];
    for (int j = max(2, t1); j <= t2; ++j) vis[pri[i] * j] = 0;
  }
  for (int i = max(5, l / 4 * 4 + 1); i <= r; i += 4)
    if (i >= l && vis[i]) ++ans;
  printf("%d", ans);
  return 0;
}
