#include <bits/stdc++.h>
using namespace std;
const int N = 3000 * 1000 * 100 + 3;
int l, r, ans;
bitset<N> b;
void qrbal() {
  int i = 2;
  b.set(1);
  if (l < 3 && r > 1) ans = 1;
  for (i = 3; i * i < r + 1; i += 2)
    if (b[i] == false) {
      for (int j = i * i; j < r + 1; j += i) b.set(j);
    }
  if (l % 2 == 0) l++;
  for (i = l; i < r + 1; i += 2)
    if (i % 4 == 1 && b[i] == false) ans++;
}
int main() {
  ios::sync_with_stdio(0), cout.tie(0), cout.tie(0);
  cin >> l >> r;
  qrbal();
  cout << ans << endl;
  return 0;
}
