#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
int a, b, ans;
bitset<300000005> s;
void init(int r) {
  s[1] = 1;
  for (int i = 3; i * i <= r; i += 2) {
    if (!s[i]) {
      if (1LL * i * i <= r) {
        for (int j = i * i; j <= r; j += i) {
          s[j] = 1;
        }
      }
    }
    s[i - 1] = 1;
  }
  s[2] = 0;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cout.precision(6);
  cerr.precision(7);
  ;
  cin >> a >> b;
  init(b);
  for (int i = (a / 4) * 4 + 1; i <= b; i += 4)
    if (i >= a && !s[i]) ++ans;
  if (a <= 2 && 2 <= b) ++ans;
  cout << ans;
  return 0;
}
