#include <bits/stdc++.h>
using namespace std;
const int MAXN = 300000005;
bitset<MAXN> pri;
void shai(int m) {
  pri.set();
  for (int i = 3; i * i <= m; i += 2) {
    if (pri[i]) {
      for (int j = i * i; j <= m; j += i << 1) pri[j] = false;
    }
  }
}
int work(int l, int r) {
  int cnt;
  cnt = l <= 2 && r >= 2;
  shai(r);
  for (int i = 5; i <= r; i += 4) {
    if (pri[i] && i >= l) {
      cnt++;
    }
  }
  return cnt;
}
int main() {
  int a, b;
  cin >> a >> b;
  cout << work(a, b) << endl;
}
