#include using namespace std; class Sieve { private: vector is_pr; vector pr; public: Sieve(int n) : is_pr(n + 1, true) { if (0 < n + 1) is_pr.at(0) = false; if (1 < n + 1) is_pr.at(1) = false; for (int i = 2; i * i <= n; i++) { if (!is_pr.at(i)) continue; for (int j = i * i; j <= n; j += i) is_pr.at(j) = false; } for (int i = 2; i < n + 1; i++) { if (is_pr.at(i)) pr.push_back(i); } } vector getB() { return is_pr; } vector getP() { return pr; } }; int main() { int N; cin >> N; Sieve S(N * 3); auto P = S.getP(); long ans = 0; vector cnt(N * 3 + 1); for (int c = 0; c < P.size(); c++) { if (P.at(c) > N) break; for (int n = c + 1; n < P.size(); n++) { ans += cnt.at(P.at(n) - P.at(c)); } int b = c; for (int a = 0; a < b; a++) { cnt.at(P.at(a) + P.at(b))++; } } cout << ans << "\n"; }