#include <bits/stdc++.h>
using namespace std;
const int MAXN = 300000000 + 10;
bitset<MAXN> check;
void Get_prime(int n) {
  check.set();
  check[0] = check[1] = 0;
  for (int i = 2; i <= sqrt(n + 0.5); ++i) {
    if (check[i])
      for (int j = 2; i * j <= n; ++j) check[i * j] = 0;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int l, r;
  cin >> l >> r;
  Get_prime(r);
  int cnt = 0, i;
  if (l <= 2 && 2 <= r) ++cnt;
  if (l % 4 <= 1)
    i = l / 4 * 4 + 1;
  else
    i = (l / 4 + 1) * 4 + 1;
  for (i; i <= r; i += 4)
    if (check[i]) ++cnt;
  cout << cnt;
}
