#include <bits/stdc++.h>
using namespace std;
vector<bool> f(150000000, 0);
int Rand() { return (rand() << 15) | rand(); }
int main() {
  int a, b, i, j, temp, answer;
  srand((unsigned)time(0));
  scanf("%d%d", &a, &b);
  f.clear();
  temp = (int)(sqrt(b));
  for (i = 3; i <= temp; i += 2)
    if (!f[i >> 1]) {
      for (j = i * i; j <= b; j += i << 1) {
        f[j >> 1] = true;
      }
    }
  answer = 0;
  if (a <= 2 && 2 <= b) {
    answer++;
  }
  if (a == 1) {
    a++;
  }
  for (i = a / 4 * 4 + 1; i <= b; i += 4)
    if (a <= i && i <= b && !f[i >> 1]) {
      answer++;
    }
  printf("%d\n", answer);
  return 0;
}
