#include <bits/stdc++.h>
using namespace std;
int l, r, ans;
bitset<300000001> b;
int main() {
  cin >> l >> r;
  for (int i = 3; i <= sqrt(r); i += 2) {
    if (!b[i]) {
      for (int j = i * i; j <= r; j += i << 1) b[j] = 1;
    }
  }
  if (l <= 2 && r >= 2) ans++;
  while (l % 4 != 1 || l == 1) l++;
  for (int i = l; i <= r; i += 4) {
    if (!b[i]) ans++;
  }
  cout << ans;
}
