#include <bits/stdc++.h>
#pragma GCC target("avx,tune=native")
using namespace std;
bitset<300000013> unprime;
int main() {
  if (fopen("FILENAME.in", "r")) {
    freopen("FILENAME.in", "r", stdin);
    freopen("FILENAME.out", "w", stdout);
  }
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long l, r;
  cin >> l >> r;
  unprime[0] = 1;
  unprime[1] = 1;
  for (int i = 2; i <= r; i++) {
    if (unprime[i]) continue;
    if (i < 20000) {
      for (int j = i * i; j <= r; j += i) {
        unprime[j] = 1;
      }
    }
  }
  int answer = (l <= 2 && 2 <= r ? 1 : 0);
  int temp = l % 4;
  for (int i = l; i <= r; i++) {
    if (!unprime[i] && temp == 1) answer++;
    temp++;
    if (temp == 4) temp = 0;
  }
  cout << answer << endl;
}
