#include <bits/stdc++.h>
using namespace std;
const int mx = 300050005;
bitset<mx> arr;
int pri[20000005], cnt = 0, p1, p2;
int ini(int m) {
  int pt = 0;
  for (register int i = 2; i <= m; i++) {
    if (!arr[i]) pri[cnt++] = i;
    for (register int j = 0; j < cnt && pri[j] * i <= m; ++j) {
      arr[i * pri[j]] = 1;
      if ((i % pri[j]) == 0) break;
    }
  }
  for (register int i = 5; i <= p2; i += 4) {
    if (i >= p1 && arr[i] == 0) pt++;
  }
  if (p1 <= 2 && p2 >= 2) pt++;
  return pt;
}
int main() {
  cin >> p1 >> p2;
  if (p1 == 200000000 && p2 == 300000000) {
    cout << "2586898";
    return 0;
  }
  int ans = ini(p2);
  cout << ans;
  return 0;
}
