#include <bits/stdc++.h>
using namespace std;
const int Max = 17500;
int prim[Max];
bitset<Max> vis;
bitset<300000000 / 4 + 10> sign;
void is_prim() {
  vis[0] = vis[1] = 1;
  register int num = 0;
  for (register int i = 2; i <= Max; i++) {
    if (!vis[i]) {
      num++;
      prim[num] = i;
    }
    for (register int j = 1; ((j <= num) && (i * prim[j] <= Max)); j++) {
      vis[i * prim[j]] = 1;
      if (i % prim[j] == 0) break;
    }
  }
}
int num(int l, int r) {
  int p = 2014;
  for (register int i = 2; i <= p + 1 && prim[i] * prim[i] <= r; i++) {
    int cnt = l / prim[i];
    if (cnt * prim[i] < l) cnt++;
    if (cnt == 1) cnt++;
    for (int j = cnt * prim[i]; j <= r; j += prim[i])
      if (j % 4 == 1) sign[j >> 2] = 1;
  }
  int ans = 0;
  for (register int j = l; j <= r; j += 4)
    if (j % 2 && !sign[j >> 2]) ans++;
  return ans;
}
int main() {
  int l, r;
  is_prim();
  int ans = 0;
  scanf("%d %d", &l, &r);
  if (l <= 2 && r >= 2) ans++;
  while (l % 4 != 1 || l == 1) l++;
  while (r % 4 != 1) r--;
  ans += num(l, r);
  printf("%d\n", ans);
}
