#include <bits/stdc++.h>
using namespace std;
const int N = int(3e8 + 10);
bitset<N> v;
int main() {
  v.set();
  int ans = 0;
  int l, r;
  scanf("%d%d", &l, &r);
  for (int i = 3; i * i <= r; i += 2)
    if (v[i]) {
      for (int j = i * i, a(i << 1); j <= r; j += a) v[j] = false;
    }
  if (l <= 2 && 2 <= r) ans++;
  for (int i = 3; i <= r; i += 2)
    if (i >= l && v[i] && ((i & 3) == 1)) ans++;
  printf("%d\n", ans);
}
