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