import math def prime_number(n): # n >= 2 prime = [] limit = math.sqrt(n) data = [i + 1 for i in range(1, n)] while True: p = data[0] if limit <= p: return prime + data prime.append(p) data = [e for e in data if e % p != 0] l, r = map(int, input().split()) if r*(r+1) - l*(l-1) // 2 <= 1: p = set() else: p = set(prime_number(r*(r+1) // 2)) ans = 0 for i in range(l, r+1): tmp = 0 for j in range(i, r+1): tmp += j if tmp in p: ans += 1 print(ans)