#include using namespace std; vector primes2(int N){ // returns a list of prime numbers up to N (including N). if (N == 1) return vector{}; if (N == 2) return vector{2}; if (N <= 4) return vector{2, 3}; vector isPrime(N + 1, true); for (int p = 5, d = 2; p * p <= N; p += d, d = 6 - d){ if (isPrime[p]){ for (int q = p * p, delta = d; q <= N; q += delta * p, delta = 6 - delta){ isPrime[q] = false; } } } vector primes = {2, 3}; for (int p = 5, d = 2; p <= N; p += d, d = 6 - d){ if (isPrime[p]) primes.push_back(p); } return primes; } int main(){ int N; cin >> N; vector ps = primes2(3 * N); vector ds((3 * N)/2 + 1, 0); for (auto p : ps) ds[p/2] = 1; vector hps; for (int i = 1; ps[i] <= N; ++i){ hps.push_back(ps[i]/2); } vector ab(N, 0); long long cnt = 0; for (int i = 1; i < hps.size(); ++i){ for (int j = 1; j < hps[i] * 2; ++j){ if (ab[j] and ds[j + hps[i] + 1]) cnt += ab[j]; } for (int j = 0; j < i; ++j) ab[hps[j] + hps[i]] += 1LL; } cout << cnt << endl; return 0; }