#include using namespace std; #define FOR(i,s,t) for(int i = s; i < t; i++) using LL = long long; using VL = vector; pair> make_prime(long long N) { vectora; vector prime(N + 1); FOR(i, 0, N + 1) { prime[i] = 1; }prime[0] = prime[1] = 0; for (LL i = 2; i <= N; i++) { if (prime[i]) { a.push_back((long long)i); for (LL j = i * 2; j <= N; j += i) prime[j] = 0; } } return { a,prime }; } int main() { int N; cin >> N; auto primes = make_prime(N); VL Ps = primes.first; // 41538 auto isprime = primes.second; LL ans = 0; FOR(i, 0, (int)Ps.size()) { LL r = Ps[i]; if (r*r > 2 * N)break; FOR(j, 0, (int)Ps.size()) { LL p = Ps[j]; LL q = r * r - p; if (0 <= q && q <= N) { ans += isprime[q]; } } } cout << ans << endl; }