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