from collections import deque from collections import defaultdict def Eratosthenes(N): is_prime = [1 for i in range(N+1)] is_prime[0] = is_prime[1] = 0 P = [] for p in range(2,N+1): if is_prime[p] == 0: continue P.append(p) for d in range(2,N+1): q = p*d if q > N: break is_prime[q] = 0 return P N = int(input()) P = Eratosthenes(300000) P = deque(P) d = defaultdict(int) Q = [] ans = 0 m = 0 while len(P): c = P.popleft() if c > N: break for p in P: if p - c > m: break ans += d[p-c] for p in Q: d[p+c] += 1 if c >= 3: m = Q[-1] + c Q.append(c) print(ans)