#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e8 + 10;
int l, r, ans;
bitset<maxn> b;
int main() {
  scanf("%d%d", &l, &r);
  for (int i = 3; i * i <= r; i += 2)
    if (!b[i])
      for (long long j = 1LL * i * i; j <= r; j += i << 1) b[j] = 1;
  for (int i = 5; i <= r; i += 4)
    if (i >= l && !b[i]) ans++;
  printf("%d", ans + (l <= 2 && 2 <= r));
  return 0;
}
