#include <bits/stdc++.h>
using namespace std;
bitset<300000010> su;
int main() {
  su[1] = 1;
  int l, r, ans = 0;
  cin >> l >> r;
  if (l < 3 && r > 1) ans++;
  for (int i = 3; i * i <= r; i += 2)
    if (!su[i])
      for (long long j = 1LL * i * i; j <= r; j += i << 1) su[j] = 1;
  while (l % 4 != 1) l++;
  for (int i = l; i <= r; i += 4)
    if (!su[i]) ans++;
  cout << ans;
  return 0;
}
