#include <bits/stdc++.h>
using namespace std;
inline int setBit(int mask, int pos) { return (mask | (1 << pos)); }
inline int resetBit(int mask, int pos) { return (mask & ~(1 << pos)); }
inline bool checkBit(int mask, int pos) { return (bool)(mask & (1 << pos)); }
int l, r;
bitset<300000005> mark;
void sieve(int lim) {
  mark.set(1);
  for (int i = 4; i <= lim; i += 2) mark[i] = true;
  int sql = sqrt(lim);
  for (int i = 3; i <= sql; i += 2) {
    if (!mark[i]) {
      for (long long int j = (long long int)i * (long long int)i; j <= lim;
           j += (2 * i))
        mark.set(j);
    }
  }
}
void solve() {
  int res = 0;
  for (int i = l; i <= r; i++) {
    if (!mark.test(i) && !((i - 1) % 4)) res++;
    if (i == 2) res++;
  }
  cout << res << endl;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> l >> r;
  sieve(r);
  solve();
  return 0;
}
