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