#ifdef LOCAL #define _GLIBCXX_DEBUG #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__) #else #define debug(...) {} #endif #include using namespace std; #include using namespace atcoder; #define ll long long #define ld long double #define rep(i, n) for(int i=0; i<(n); ++i) #define rep1(i, n) for(int i=1; i<=(n); ++i) #define rrep(i,n) for(int i = (n)-1; i >= 0; --i) #define rrep1(i,n) for(int i = (n); i >= 1; --i) #define FOR(i, a, b) for(int i=(a); i<(b); ++i) #define RFOR(i, a, b) for(int i=(b)-1; i>=(a); --i) #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(), x.rend() #define mp make_pair #define fi first #define se second #define pb push_back #define eb emplace_back #define sz(x) (int)(x).size() #define popcnt(x) __builtin_popcountll(x) #define isin(x,l,r) ((l) <= (x) && (x) < (r)) #define newline puts("") templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b; using pll = pair; using pdd = pair; template using v = vector; template using vv = v>; using vi = vector; using vb = vector; using vl = vector; using vd = vector; using vs = vector; using vpii = vector; using vpl = vector; using vpd = vector; template using pqg = priority_queue,greater>; using int128 = __int128_t; using mint = atcoder::modint1000000007; const ll MOD = 1000000007; // using mint = atcoder::modint998244353; // const ll MOD = 998244353; // using mint = atcoder::modint; //mint::set_mod(mod); /** debug **/ template string to_string(pair p); template string to_string(tuple p); template string to_string(tuple p); string to_string(const string& s) { return '"' + s + '"'; } string to_string(const char* s) { return to_string((string) s); } string to_string(bool b) { return (b ? "true" : "false"); } string to_string(mint x) { return to_string(x.val()); } string to_string(vector v) { bool first = true; string res = "{"; for (int i = 0; i < static_cast(v.size()); i++) { if (!first) { res += ", "; } first = false; res += to_string(v[i]); } res += "}"; return res; } template string to_string(bitset v) { string res = ""; for (size_t i = 0; i < N; i++) { res += static_cast('0' + v[i]); } return res; } template string to_string(A v) { bool first = true; string res = "{"; for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); } res += "}"; return res; } template string to_string(pair p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; } template string to_string(tuple p) { return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")"; } template string to_string(tuple p) { return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")"; } void debug_out() { cerr << endl; } template void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...); } #define endl '\n' const int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1}; const long double eps= 1e-10; const long double PI = 3.141592653589793238462643383279502884L; const int INF = 1001001001; const ll LINF = 1001002003004005006ll; struct EratosSieve { int n; vector f, primes; EratosSieve(int n=1):n(n), f(n+1) { f[0] = f[1] = -1; for (ll i = 2; i <= n; ++i) { if (f[i]) continue; primes.push_back(i); f[i] = i; for (ll j = i*i; j <= n; j += i) { if (!f[j]) f[j] = i; } } } bool isPrime(int x) { return f[x] == x;} vector _factorList(int x) { vector res; while (x != 1) { res.push_back(f[x]); x /= f[x]; } return res; } vector> factorize(int x) { vector fl = _factorList(x); if (fl.size() == 0) return {}; vector> res(1, pair(fl[0], 0)); for (int p : fl) { if (res.back().first == p) { res.back().second++; } else { res.emplace_back(p, 1); } } return res; } vector> factorize(ll x) { vector> res; for (int p : primes) { int y = 0; while (x%p == 0) x /= p, ++y; if (y != 0) res.emplace_back(p,y); } if (x != 1) res.emplace_back(x,1); return res; } }; void solve() { int N; cin >> N; EratosSieve era(3 * N); vi ps = era.primes; int M = sz(ps); vl dp(3 * N + 1); ll ans = 0; for(int i=0;ps[i] <= N;i++){ int c = ps[i]; FOR(j, i+1, M){ int s = ps[j]; ans += dp[s - c]; } rep(j, i){ dp[ps[j] + ps[i]]++; } } debug(dp); cout << ans << endl; } int main(){ int tests = 1; // scanf("%d", &tests); ios::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(15); rep1(i, tests){ solve(); } return 0; }