#include <bits/stdc++.h>
using namespace std;
const double EPS = 0.0000001;
const double PI = acos(-1);
const long long INFLL = 0x7FFFFFFFFFFFFFFF;
const int INF = 0x7FFFFFFF;
template <typename T>
inline void next(T &num) {
  char c;
  num = 0;
  do {
    c = getchar_unlocked();
  } while (c != EOF && c == ' ' && c == '\n' && c == '\t');
  int sign = (c == '-' ? -1 : 1);
  if (c != '-') num += (c - '0');
  while ((c = getchar_unlocked()) != EOF && c != '\n' && c != '\t' &&
         c != ' ') {
    num *= 10;
    num += (c - '0');
  }
  num *= sign;
}
inline string getstr() {
  string str;
  char k;
  while ((k = getchar_unlocked()) == ' ' || k == '\n') {
    k = getchar_unlocked();
    if (k == ' ' || k == '\n')
      continue;
    else
      break;
  }
  str.push_back(k);
  while ((k = getchar_unlocked()) != EOF && k != '\n' && k != '\t' &&
         k != '\v' && k != '\0' && k != ' ')
    str.push_back(k);
  return str;
}
const int N = 300000005;
bitset<N> isprim;
int l, r;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> l >> r;
  isprim.set();
  int ans = (l <= 2 && r >= 2), i;
  for (i = 3; i * i <= r; i += 2)
    if (isprim[i]) {
      ans += (i >= l && i % 4 == 1);
      for (int j = 3 * i; j <= r; j += 2 * i) isprim[j] = 0;
    }
  i = max(i, l);
  if (i % 4 != 1) i = (i + 3) / 4 * 4 + 1;
  for (; i <= r; i += 4) {
    ans += (i >= l && isprim[i]);
  }
  cout << ans;
  return 0;
}
