#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
const int N = 300066666;
bitset<N> nprime;
int prime_n, prime[20000005];
int n, m, ans;
int main() {
  nprime[1] = 1;
  scanf("%d%d", &n, &m);
  for (register int i = 2; i <= m; ++i) {
    if (nprime[i] == 0) ++prime_n, prime[prime_n] = i;
    for (register int j = 1; j <= prime_n && i * prime[j] <= m; ++j) {
      nprime[i * prime[j]] = 1;
      if (i % prime[j] == 0) break;
    }
  }
  for (register int i = 5; i <= m; i += 4)
    if (i >= n && nprime[i] == 0) ++ans;
  if (n <= 2 && m >= 2) ++ans;
  printf("%d\n", ans);
  return 0;
}
