#include <bits/stdc++.h>
using namespace std;
bitset<300000001> b;
int main() {
  int l, r, c = 0, i, j;
  cin >> l >> r;
  for (i = 3; i * i <= r; i += 2)
    for (j = i * i; b[i] == 0 and j <= r; j += i) b[j] = 1;
  if (l <= 2 and r >= 2) c = 1;
  for (i = 5; i <= r; i += 4) c += !b[i] and i >= l;
  cout << c;
}
