#include <bits/stdc++.h>
using namespace std;
vector<bool> v(150000000, 0);
int l, r;
int calc() {
  int Sq = (int)sqrt((r << 1) + 1.0);
  for (int i = 3, j; i <= Sq; i += 2) {
    if (v[i >> 1]) continue;
    for (j = i * i; j <= r; j += (i << 1)) v[j >> 1] = 1;
  }
  int ans = 0;
  if (l <= 2 && 2 <= r) ++ans;
  if (l == 1) l += 4;
  if (l % 4 == 0) l += 1;
  if (l % 4 == 2) l += 3;
  if (l % 4 == 3) l += 2;
  while (l <= r) {
    if (!v[l >> 1]) ++ans;
    l += 4;
  }
  return ans;
}
int main() {
  cin >> l >> r;
  cout << calc() << endl;
  return 0;
}
