#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7, siz = 3e8 + 5;
int l, r;
bitset<siz> f;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> l >> r;
  int ans = (l <= 2 and r >= 2);
  for (int i = 3; i * i <= r; i += 2) {
    if (f[i]) continue;
    for (int j = i * i; j <= r; j += i) f[j] = 1;
  }
  for (int i = 5; i <= r; i += 4) ans += (i >= l and !f[i]);
  printf("%d\n", ans);
}
