#include <bits/stdc++.h>
using namespace std;
int l, r;
int ans;
int pri[20000005], cnt;
bitset<300000005> vis;
void prime() {
  for (int i = 2; i <= r; i++) {
    if (!vis[i]) {
      pri[++cnt] = i;
      if (i >= l && i % 4 == 1) ans++;
    }
    for (int j = 1; j <= cnt && pri[j] * i <= r; j++) {
      vis[pri[j] * i] = 1;
      if (i % pri[j] == 0) break;
    }
  }
}
int main() {
  scanf("%d%d", &l, &r);
  prime();
  if (r >= 2 && l <= 2) ans++;
  printf("%d", ans);
}
