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