#define _USE_MATH_DEFINES #include using namespace std; signed main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector primes, is_prime(n + 1, 1); is_prime[0] = 0; is_prime[1] = 0; for (int i = 2; i <= n; i++) { if (!is_prime[i]) continue; primes.push_back(i); for (int j = i + i; j <= n; j += i) { is_prime[j] = 0; } } long long ans = 0; for (long long x : primes) { if (x * x - 2 > n) continue; else if (is_prime[x * x - 2]) { if (x * x - 2 == 2) ans++; else ans += 2; } } cout << ans << endl; return 0; }