def is_prime(x): if x == 2: return True if x == 1 or x % 2 == 0: return False for k in range(3, int(x ** 0.5) + 1, 2): if x % k == 0: return False return True l, r = map(int, input().split()) ans = 0 for i in range(1, 10 ** 6 + 1): a = i b = i + 1 if l <= a <= r and l <= b <= r: ab = a + b if is_prime(ab): ans += 1 a = i b = i if l <= a <= r and l <= b <= r: if is_prime(a): ans += 1 print(ans)