#include <bits/stdc++.h>
using namespace std;
bitset<300000000 + 5> p;
void prime_list(int n) {
  p.set();
  int t = sqrt(n);
  for (int i = 3; i <= t; i += 2)
    if (p[i]) {
      for (int j = i * i; j <= n; j += 2 * i) p[j] = 0;
    }
}
int main() {
  int l, r, c = 0;
  scanf("%d%d", &l, &r);
  prime_list(r);
  c = l <= 2 && r >= 2;
  for (int i = max(l / 4 * 4 + 1, 5); i <= r; i += 4)
    if (i >= l && p[i]) c++;
  printf("%d", c);
}
