#include <bits/stdc++.h>
const int maxn = 3e8 + 10;
using namespace std;
bitset<maxn> prm;
int cnt;
void prime(int n, int m) {
  prm.set();
  for (int i = 3; i * i <= m; i += 2) {
    if (prm[i]) {
      for (int j = i * i; j <= m; j += i) prm[j] = false;
    }
  }
  if (n <= 2) cnt++;
  for (int i = max(5, n / 4 * 4 + 1); i <= m; i += 4) {
    if (i >= n && prm[i]) cnt++;
  }
  printf("%d", cnt);
}
int main() {
  int n, m;
  int ans = 0;
  scanf("%d%d", &n, &m);
  if (n == 1 && m == 1) {
    printf("0");
    return 0;
  }
  if (n == 1 && m == 1) {
    printf("0");
    return 0;
  }
  if (n == 1 && m == 2) {
    printf("1");
    return 0;
  }
  if (n == 2 && m == 2) {
    printf("1");
    return 0;
  }
  prime(n, m);
  return 0;
}
