N = int(input()) p1 = [] p2 = [] p = set() C = 3 * N+1 dat = [0] * C for i in range(2,C,2): dat[i] = 1 for i in range(3,C): if dat[i] == 0: if i <= N: if i % 3 == 1: p1.append(i) elif i % 3 == 2: p2.append(i) p.add(i) for j in range(i * 2,C,i): dat[j] = 1 dat = [0] * (2 * N) for i in range(len(p1)): for j in range(i + 1,len(p1)): dat[p1[i]+p1[j]] += 1 dat2 = [0] * C for i in p2: for j in range(20,2 * N,3): dat2[j+i] += dat[j] for j in range(20,2 * N,3): dat2[j+3] += dat[j] ans = 0 for v in p: ans += dat2[v] dat = [0] * (2 * N) dat2 = [0] * C for i in range(len(p2)): for j in range(i + 1,len(p2)): dat[p2[i]+p2[j]] += 1 for i in p1: for j in range(16,2 * N,3): dat2[i+j] += dat[j] for j in range(16,2 * N,3): dat2[j+3] += dat[j] for v in p: ans += dat2[v] print(ans)