#include "bits/stdc++.h" using namespace std; using ll = int64_t; using ld = long double; using ull = unsigned long long; #define ALL(x) x.begin(),x.end() #define rep(iter,from,to) for(ll iter=from;iter dx{ 1,0,-1,0 }, dy{ 0,1,0,-1 }; //####################################################################### void op(vector vec) { ll size = (ll)vec.size(); for (ll i = 0; i < size - 1; ++i) cout << vec[i] << " "; cout << vec.back() << endl; } void op(vector> vec) { ll height = (ll)vec.size(); ll width = (ll)vec[0].size(); for (ll i = 0; i < height; ++i) { for (ll j = 0; j < width - 1; ++j) cout << vec[i][j] << " "; cout << vec[i].back() << endl; } } void twoText(bool identifier, string outTrue, string outFalse) { if (identifier) cout << outTrue << endl; else cout << outFalse << endl; } void twoText(bool identifier) { if (identifier) cout << "Yes" << endl; else cout << "No" << endl; } template T vecsum(vector& vec) { return accumulate(ALL(vec), (T)0); } template T vecsum(vector& vec, ll K) { ll ret = 0; rep(i, 0, K) ret += vec[i]; return ret; } template struct grid { vector> field; grid(ll height, ll width) { field = vector>(height, vector(width, (T)0)); } void input() { rep(i, 0, field.size()) rep(j, 0, field[i].size()) cin >> field[i][j]; } }; //######################################################################### bool isPrime(ll Num) { ll root = sqrt(Num); if (Num == 0 || Num == 1) return false; for (ll i = 2; i <= root; ++i) if (Num % i == 0) return false; return true; } vector enumeratePrime(ll maxx) { vector notp(maxx + 1, false); vector ret; rep(i, 2, maxx) { if (notp[i]) continue; if (isPrime(i)) ret.emplace_back(i); ll init = 1; while (init * i <= maxx) { notp[init * i] = true; init++; } } return ret; } void solve() { ll N; cin >> N; auto primes = enumeratePrime(N); unordered_set primeSet; fore(x, primes) primeSet.emplace(x); ll ans = 0; fore(r, primes) { if (r * r > 2 * N) break; for (ll p = 2; p <= r * r / 2; ++p) { if (!isPrime(p)) continue; ll q = r * r - p; if (primeSet.find(q) != primeSet.end()) { if (p == q) ans++; else ans += 2; } } } cout << ans << endl; } int main(void) { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(15); solve(); }