#include #include using namespace std; int main(){ int N; cin >> N; vector prime(N + 1, true); prime[0] = false; prime[1] = false; for (int i = 2; i <= N; i++){ if (prime[i]){ for (int j = i * 2; j <= N; j += i){ prime[j] = false; } } } int ans = 0; if (N >= 2){ ans++; } for (int i = 3; i * i <= N + 2; i++){ if (prime[i] && prime[i * i - 2]){ ans += 2; } } cout << ans << endl; }