#include <bits/stdc++.h>
using namespace std;
bitset<300000000> pd;
int prime[20000000];
int l, r, num, ans;
void euler() {
  for (register int i = 2; i <= r; i++) {
    if (pd[i] == 0) prime[++num] = i;
    for (register int j = 1; j <= num && prime[j] * i <= r; j++) {
      pd[prime[j] * i] = 1;
      if (i % prime[j] == 0) break;
    }
  }
}
int main() {
  cin >> l >> r;
  euler();
  for (register int i = 1; i <= num; i++) {
    if (prime[i] < l) continue;
    if (prime[i] % 4 == 1) ans++;
  }
  if (l <= 2 && r >= 2) ans++;
  cout << ans;
  return 0;
}
