#include using namespace std; #ifdef LOCAL #include "settings/debug.cpp" #else #define Debug(...) void(0) #endif #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; int main() { cin.tie(nullptr)->sync_with_stdio(false); int n; cin >> n; if (n == 1) { cout << 0 << '\n'; return 0; } vector is_prime(n + 1, true); set primes; is_prime[0] = is_prime[1] = false; for (ll i = 2; i <= n; ++i) { if (is_prime[i]) { primes.insert(i); for (ll j = i * i; j <= n; j += i) is_prime[j] = false; } } int ans = -1; for (ll x : primes) { if (x * x - 2 <= n && primes.contains(x * x - 2)) ans += 2; } cout << ans << '\n'; return 0; }