#include <bits/stdc++.h>
using namespace std;
unsigned int p[9375001], l, r, ans, pri[17000000], p_;
inline void S(unsigned int x) { p[x >> 5] |= (1 << (x & 31)); }
inline bool P(unsigned int x) { return p[x >> 5] & (1 << (x & 31)); }
int main() {
  cin >> l >> r;
  S(1);
  p_ = 0;
  for (unsigned int i = 3, j, k; i <= r; i += 2) {
    if (!P(i)) pri[p_++] = i;
    for (j = 0; (k = i * pri[j]) <= r && i % pri[j] && j < p_; j++) S(k);
    if (k <= r) S(k);
  }
  if (2 >= l && 2 <= r) ans++;
  if (~l & 1) l++;
  if ((l & 3) == 3) l += 2;
  for (unsigned int i = l; i <= r; i += 4)
    if (!P(i)) ans++;
  cout << ans << endl;
  return 0;
}
