#include <bits/stdc++.h>
using namespace std;
bitset<300000005> p;
int main() {
  p.set();
  long long int l, r, c = 0;
  cin >> l >> r;
  for (int i = 3; i * i <= r; i += 2) {
    if (p[i]) {
      for (int j = i * i; j <= r; j += 2 * i) {
        p[j] = 0;
      }
    }
  }
  if (l <= 2 && 2 <= r) c = 1;
  for (int i = 5; i <= r; i += 4)
    if (p[i] && i >= l) c++;
  cout << c << "\n";
  return 0;
}
