#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}
bool simp(int n) {
  if (n < 2) return 0;
  for (int i = 2; i * i <= n; ++i)
    if (n % i == 0) return 0;
  return 1;
}
static bitset<300000001> bs;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int l, r, re = 0;
  cin >> l >> r;
  for (int i = 3; i * i <= r; i += 2)
    if (bs[i] == 0) {
      for (int j = (i << 1); j <= r; j += i) bs[j] = 1;
    }
  if (2 >= l && 2 <= r) ++re;
  for (int i = max(4, l); i <= r; ++i)
    if ((i & 3) == 1 && !bs[i]) ++re;
  cout << re << endl;
  return 0;
}
