#include <bits/stdc++.h>
using namespace std;
bitset<17500> check;
bitset<300000000 / 4 + 10> result;
int prime[17500];
int l, r, special = 0;
int cnt = 0;
inline void is_prime() {
  check[0] = check[1] = 1;
  for (int i = 1; i <= 17500; i++)
    if (!check[i]) {
      cnt++;
      prime[cnt] = i;
      for (int j = i * i; j <= 17500; j += i) check[j] = 1;
    }
}
inline void get_ans() {
  is_prime();
  for (int i = 1; i <= cnt; i++) {
    int haha = l / prime[i];
    if (prime[i] * haha < l) haha++;
    if (haha == 1) haha++;
    for (int j = haha * prime[i]; j <= r; j += prime[i]) {
      if (j % 4 == 1) result[(j - 1) / 4] = 1;
    }
  }
  int num = 0;
  for (int i = l; i <= r; i += 4)
    if (!result[(i - 1) / 4]) num++;
  cout << num + special << endl;
}
int main() {
  cin >> l >> r;
  if (l <= 2 && r >= 2) special = 1;
  while (l % 4 != 1 || l == 1) l++;
  while (r % 4 != 1) r--;
  get_ans();
  return 0;
}
