n = int(input()) prime = [True for _ in range(3 * n + 1)] prime[0] = prime[1] = False for x in range(2, 3 * n + 1): if not prime[x]: continue for y in range(2 * x, 3 * n + 1, x): prime[y] = False cnt = [0 for _ in range(2 * n + 1)] primes = [] ans = 0 for x in range(1, n + 1): if not prime[x]: continue if len(primes) < 1: primes.append(x) continue for s in range(x, 2 * primes[-1] + x + 1): if prime[s]: ans += cnt[s - x] for y in primes: cnt[x + y] += 1 primes.append(x) print(ans)