#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } const long long MAX = 5100000; const long long INF = 1LL << 60; const long long mod = 1000000007LL; //const long long mod = 998244353LL; using namespace std; typedef unsigned long long ull; typedef long long ll; vector isprime; void eratos(ll n) { isprime.resize(n + 1); for (ll i = 0; i <= n; i++) { isprime[i] = true; } isprime[0] = false; isprime[1] = false; for (ll i = 2; i * i <= n; i++) { if (isprime[i]) { ll j = i + i; while (j <= n) { isprime[j] = false; j = j + i; } } } } int main() { /* cin.tie(nullptr); ios::sync_with_stdio(false); */ ll N; cin >> N; eratos(1000050); vector p; for (ll i = 3; i <= N; i++) if (isprime[i]) p.push_back(i); vector h(1005000, false); for (ll i = 1; i * i <= 1000000; i++) { if(isprime[i]) h[i * i] = true; } ll res = 0; for (ll e : p) { if (h[2 + e]) res += 2; } if (N >= 2) res++; cout << res << endl; return 0; }