#include <bits/stdc++.h>
using namespace std;
bitset<300000001> a;
int main() {
  int l, r, ans = 0;
  scanf("%d%d", &l, &r);
  if (l <= 2 && r >= 2) ans = 1;
  for (int i = 3; i * i <= r; i += 2) {
    if (a[i] == 0)
      for (int j = i * i; j <= r; j += i * 2) a[j] = 1;
  }
  for (int i = 5; i <= r; i += 4)
    if (l <= i && a[i] == 0) ans++;
  printf("%d", ans);
  return 0;
}
