#include using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define llong long long vector get_primes(int n) { vector primes(n+1, true); primes[0] = false; primes[1] = false; vector ret; int limit = (int)sqrt(n)+1; for(int i=2; i<=limit; i++) { if(!primes[i]) continue; for(int j=i*i; j<=n; j+=i) { primes[j] = false; } } rep(i, n+1) { if(primes[i]) ret.push_back(i); } return ret; } int main() { int n; cin >> n; vector primes = get_primes(n); set primes2; rep(i, primes.size()) primes2.insert(primes[i] * primes[i]); int result = 0; rep(i, primes.size()) { if(primes[i]==2) continue; if(primes2.find(2+primes[i]) != primes2.end()) { result++; } } result *= 2; if(n >= 4) result += 1; cout << result << "\n"; }