#include <bits/stdc++.h>
using namespace std;
inline void read(register int *n) {
  register char c;
  *n = 0;
  do {
    c = getchar();
  } while (c < '0' || c > '9');
  do {
    *n = c - '0' + *n * 10;
    c = getchar();
  } while (c >= '0' && c <= '9');
}
const int MAXN = 3 * 10000 * 10000;
bitset<MAXN / 4 + 100> p;
int main() {
  ios::sync_with_stdio(false);
  p.set();
  for (int i = 3; i * i <= MAXN; i += 2) {
    bool bad = false;
    for (int j = 3; j <= 1000 && j < i; j += 2)
      if (i % j == 0) bad = true;
    if (bad) continue;
    int st = 2 * i;
    while (st % 4 != 1) st += i;
    int add = 4 * i;
    for (int j = st; j <= MAXN; j += add) p[j >> 2] = false;
  }
  p[0] = false;
  int L, R;
  cin >> L >> R;
  int tot = 0;
  for (int i = max(0, L / 4 - 3); i <= (R + 10) / 4; i++) {
    if (p[i] && L <= 4 * i + 1 && 4 * i + 1 <= R) tot++;
  }
  if (L <= 2 && 2 <= R) tot++;
  cout << tot << "\n";
  return 0;
}
