#include <bits/stdc++.h>
using namespace std;
const int size = 300000001;
bitset<size> gut;
int main() {
  int l, r;
  cin >> l >> r;
  gut.set();
  for (int i = 3; i * i <= r; i += 2) {
    if (gut[i])
      for (int j = i * i; j <= r; j += (i << 1)) {
        gut[j] = false;
      }
  }
  int rez = 0;
  rez = (l <= 2 && r >= 2);
  for (int i = 5; i <= r; i += 4) {
    if (i >= l && gut[i]) rez++;
  }
  cout << rez << endl;
  return 0;
}
