#include <bits/stdc++.h>
using namespace std;
const int maxn = (int)3e8 + 10;
bitset<maxn> b;
int main() {
  int l, r, j, cnt = 0;
  cin >> l >> r;
  b.set();
  for (int i = 3; i * i <= r; i += 2) {
    if (b[i])
      for (j = i * i; j <= r; j += (2 * i)) b[j] = false;
  }
  for (int i = 5; i <= r; i += 4)
    if (b[i] && l <= i) {
      cnt++;
    }
  cout << cnt + (l <= 2 && r >= 2);
}
