#include <bits/stdc++.h>
using namespace std;
const int T = 3e8 + 10;
int l, r, cnt, ans;
int prime[16253000];
bitset<T> vis;
void init(int N) {
  for (int i = 2; i <= N; i++) {
    if (vis[i] == 0) prime[++cnt] = i;
    for (int j = 1; j <= cnt && i * prime[j] <= N; j++) {
      vis[i * prime[j]] = 1;
      if (i % prime[j] == 0) break;
    }
  }
}
int main() {
  scanf("%d%d", &l, &r);
  init(r);
  for (int i = 1; i <= cnt; i++)
    if (l <= prime[i] && prime[i] <= r && (prime[i] % 4 == 1 || prime[i] == 2))
      ans++;
  printf("%d", ans);
}
