def prime_list(n): is_prime = [0] * (n + 1) is_prime[2] = 1 for i in range(3, n+1, 2): is_prime[i] = 1 for i in range(2, int(n ** 0.5) + 1): if is_prime[i]: for j in range(i * i, n + 1, 2 * i): is_prime[j] = 0 d = [] for j in range(n + 1): if is_prime[j] == 1: d.append(j) return d l, r = map(int, input().split()) p = set(prime_list(2*r + 1)) ans = 0 for i in range(l, r): if i in p: ans += 1 if 2*i + 1 in p: ans += 1 if r in p: ans += 1 print(ans)