#include <bits/stdc++.h>
using namespace std;
const long N = (long)3e8 + 10;
long l, r, i, j, X;
bitset<N> g;
int main() {
  cin >> l >> r;
  g.set();
  X = 0;
  if ((l <= 2) && (r >= 2)) X++;
  if (l <= 2) l = 3;
  for (i = 3; (j = i * i) <= r; i += 2)
    if (g[i]) {
      for (; j <= r; j += (i << 1)) g[j] = 0;
    }
  while ((l & 3) != 1) l++;
  for (i = l; i <= r; i += 4)
    if (g[i]) X++;
  cout << X << "\n";
  return 0;
}
