import numpy as np n = int(input()) sieve = np.ones(n*3+1, dtype=bool) for i in range(2, int((n*3)**0.5)+2): if sieve[i]: sieve[i+i::i] = False ps1 = np.where(sieve)[0][2:] ps2 = ps1[ps1 <= n] cnt = np.zeros(n*3+1, dtype='int64') res = 0 for i in reversed(range(len(ps2))): a = ps2[i] res += cnt[ps1 - a].sum() cnt[ps2[i+1:] + a] += 1 print(res)