#include <bits/stdc++.h>
using namespace std;
int l, r, p[20000010], k = 0, tot = 0;
bitset<300000005> vis;
int main() {
  scanf("%d%d", &l, &r);
  for (int i = 2; i <= r; i++) {
    if (!vis[i]) p[++k] = i;
    for (int j = 1; j <= k && i * p[j] <= r; j++) {
      vis[i * p[j]] = 1;
      if (i % p[j] == 0) break;
    }
  }
  for (int i = 1; i <= k; i++)
    if (p[i] >= l && p[i] % 4 == 1) tot++;
  if (l <= 2 && r >= 2) tot++;
  printf("%d\n", tot);
}
