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