#include <bits/stdc++.h>
using namespace std;
bitset<300000001> I;
int l, r, sol, i, j;
int main() {
  scanf("%d%d", &l, &r);
  I.set();
  for (i = 3; i * i <= r; i += 2)
    if (I[i])
      for (j = i * i; j <= r; j += i + i) I[j] = false;
  for (i = 5; i <= r; i += 4)
    if (I[i] && l <= i) sol++;
  printf("%d\n", sol + (l <= 2 && 2 <= r));
}
