#include <bits/stdc++.h>
using namespace std;
bool pri[100000 + 5];
int np, prime[2000], ans, a, b;
void init() {
  int i, j, k, times, base;
  np = 0;
  prime[++np] = 2;
  for (i = 0; i < 3000; i++) {
    memset(pri, true, sizeof(pri));
    for (j = 2; j <= np; j++) {
      if (prime[j] <= (i + 1) * 100000 / prime[j]) {
        times = i * 100000 / prime[j];
        base = times * prime[j];
        if (base <= i * 100000) base += prime[j];
        if (!(base & 1)) base += prime[j];
        base = max(base, prime[j] * prime[j]);
        for (k = base; k <= (i + 1) * 100000; k += (prime[j] << 1)) {
          pri[k - i * 100000] = 0;
        }
      }
    }
    if (i == 0) pri[1] = 0;
    for (j = 1; j <= 100000; j += 2) {
      if (pri[j]) {
        prime[++np] = i * 100000 + j;
        if (!(1 & (prime[np] >> 1))) {
          if (a <= prime[np] && prime[np] <= b) ans++;
        }
        if (prime[np] <= (i + 1) * 100000 / prime[np]) {
          for (k = prime[np] * prime[np]; k <= (i + 1) * 100000;
               k += (prime[np] << 1)) {
            pri[k - i * 100000] = 0;
          }
        } else {
          if (prime[np] > 300000000 / prime[np]) np--;
        }
      }
    }
  }
}
int main() {
  while (scanf("%d%d", &a, &b) != EOF) {
    ans = 0;
    init();
    if (a <= 2 && 2 <= b) ans++;
    printf("%d\n", ans);
  }
  return 0;
}
