#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using ll = long long;
using uint = unsigned int;
using db = long double;
const int N = 5e5 + 5, MOD = 1e9 + 7;
using ii = pair<int, int>;
bitset<300000001> bt, pr;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int l, r;
  cin >> l >> r;
  if (r == 1) {
    cout << 0 << '\n';
    return 0;
  }
  for (int i = 2; i * i <= r; i++)
    if (!pr[i])
      for (int j = i * i; j <= r; j += i) pr[j] = 1;
  for (int i = 1; i * i <= r; i++) {
    for (int j = i + 1; i * i + j * j <= r; j += 2) {
      if (i * i + j * j >= l && !pr[i * i + j * j]) {
        bt.set(i * i + j * j);
      }
    }
  }
  cout << bt.count() + (l <= 2) << '\n';
  return 0;
}
