#include using namespace std; int main() { int N; cin >> N; vector B(N + 1, true); B.at(0) = B.at(1) = false; for (int i = 2; i <= N; i++) { if (!B.at(i)) continue; for (int j = i + i; j <= N; j += i) B.at(j) = false; } long ans = 0; for (int i = 2; i <= N; i++) { if (!B.at(i)) continue; if (i == 2) { ans++; continue; } long tmp = i + 2; if (sqrt(tmp) == (long) sqrt(tmp)) { long tmp2 = sqrt(tmp); if (tmp2 <= N && B.at(tmp2)) ans += 2; } } cout << ans << "\n"; }