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