#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
const long long INFLL = 1000000000000000000LL;
const int h = 300000000;
int l, r;
int pr[(h >> 6) + 1];
int u[15];
vector<int> o;
int main() {
  scanf("%d%d", &l, &r);
  int res = 0;
  memset(u, -1, sizeof u);
  for (int i = (0), _b = (15); i < _b; ++i)
    if ((2 * i + 1) % 3 != 0 && (2 * i + 1) % 5 != 0) {
      u[i] = int((o).size());
      o.push_back(i);
    }
  int r2 = (r - 1) / 2;
  pr[0] |= 1;
  for (int i = (1), _b = ((sqrt(2.0 * r2 + 1) + 1) / 2); i < _b; ++i)
    if ((~pr[i >> 5]) & (1 << (i & 31)))
      for (int i2 = 2 * i + 1, v = i * (i + 1) << 1; v <= r2; v += i2)
        pr[v >> 5] |= 1 << (v & 31);
  if (l <= 2 && 2 <= r) ++res;
  for (int v = 2; v <= r2; v += 2)
    if (l <= 2 * v + 1 && (~pr[v >> 5]) & (1 << (v & 31))) ++res;
  printf("%d\n", res);
  return 0;
}
