#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e7 + 5;
const int inf = 21474846495;
void read(int &x) {
  char ch;
  bool flag = 0;
  for (ch = getchar(); !isdigit(ch) && ((flag |= (ch == '-')) || 1);
       ch = getchar())
    ;
  for (x = 0; isdigit(ch); x = (x << 1) + (x << 3) + ch - 48, ch = getchar())
    ;
  x *= 1 - 2 * flag;
}
int l, r;
bitset<300000005> num;
int prime[20000005], top = 0;
int ans = 0;
void getans() {
  for (register int i = 2; i <= r; i++) {
    if (num[i] == 0) prime[++top] = i;
    if (!num[i] && i % 4 == 1 && i >= l) ans++;
    for (register int j = 1; j <= top && i * prime[j] <= r; j++) {
      num[i * prime[j]] = 1;
      if (i % prime[j] == 0) break;
    }
  }
}
int main() {
  cin >> l >> r;
  getans();
  if (l <= 2 && r >= 2) ans++;
  cout << ans;
  return 0;
}
