#include <bits/stdc++.h>
using namespace std;
bitset<300000010> am;
int is[10000000];
int z, y;
void run() {
  for (int i = 2; i <= y; i++) {
    if (!am[i]) {
      is[0]++;
      is[is[0]] = i;
    }
    for (int j = 1; j <= is[0] && i * is[j] <= y; j++) {
      am[i * is[j]] = true;
      if (i % is[j] == 0) break;
    }
  }
}
int main() {
  cin >> z >> y;
  run();
  int give = 0;
  for (int i = 1; i <= is[0]; i++) {
    if (is[i] >= z && is[i] <= y)
      if (is[i] == 2 || is[i] % 4 == 1) give++;
  }
  cout << give;
  return 0;
}
