#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  int a, b;
  cin >> a >> b;
  vector<bool> p(b + 1, true);
  p[0] = p[1] = false;
  for (long long i = 2; i * i <= b; ++i)
    if (p[i])
      for (long long j = i * i; j <= b; j += i) p[j] = false;
  int odp = 0;
  for (int i = 5; i <= b; i += 4)
    if (i >= a && i <= b && p[i]) ++odp;
  if (2 >= a && 2 <= b) ++odp;
  cout << odp;
  return 0;
}
