#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B;
  scanf("%d %d", &A, &B);
  int M = max(A, B) + 1;
  vector<bool> sito(M, false);
  vector<int> good;
  good.push_back(2);
  for (int i = 2; i < sito.size(); i += (i == 2 ? 1 : 2)) {
    bool s = sito[i];
    if (!s && i < 18000)
      for (int j = i * i, dj = (i == 2 ? 1 : 2); j < sito.size();
           j += ((j > 18000 && j % 4 == 1) ? 2 * dj : dj) * i)
        sito[j] = true;
    if (!s && i % 4 == 1) good.push_back(i);
  }
  int i1 = lower_bound(good.begin(), good.end(), A) - good.begin(),
      i2 = upper_bound(good.begin(), good.end(), B) - good.begin();
  printf("%d\n", i2 - i1);
  return 0;
}
