#include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int64_t N; cin >> N; vector is_prime(3 * N + 1, true); is_prime[0] = is_prime[1] = false; for (int64_t i = 0; i * i < 3 * N + 1; i++) { if (!is_prime[i]) continue; for (int k = 2 * i; k < 3 * N + 1; k += i) { is_prime[k] = false; } } vector primes; for (int64_t i = 0; i < N + 1; i++) { if (is_prime[i]) { primes.emplace_back(i); } } int res = 0; for (auto r : primes) { if (r * r - 2 * primes.back() > 0) break; for (auto p : primes) { auto q = r * r - p; if (q < N + 1 && q > 0 && is_prime[q]) res++; } } cout << res << '\n'; return 0; }