#include <bits/stdc++.h>
unsigned int use[9375001];
int l, r, p, c[16252326], ans;
int pos, tmp, pp, tt, u;
inline int ask(int k) {
  pos = k >> 5;
  tmp = k & 31;
  return use[pos] & (1 << tmp);
}
inline void set(int k) {
  pos = k >> 5;
  tmp = k & 31;
  use[pos] |= (1 << tmp);
}
int main() {
  scanf("%d%d", &l, &r);
  tt = 1;
  if (r > 1) {
    int i = 2;
    if (!ask(i)) c[++p] = i;
    for (int j = 1; j <= p; j++) {
      u = i * c[j];
      if (u > r) break;
      set(u);
      if (i % c[j] == 0) break;
    }
  }
  for (int i = 3; i <= r; i += 2) {
    if (!ask(i)) c[++p] = i;
    for (int j = 2; j <= p; j++) {
      u = i * c[j];
      if (u > r) break;
      set(u);
      if (i % c[j] == 0) break;
    }
  }
  for (int i = 1; i <= p; i++)
    if (c[i] >= l && (c[i] & 3) != 3) ans++;
  printf("%d\n", ans);
  return 0;
}
