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