#include using i64 = long long; int main() { int n; std::cin >> n; std::vector ps; std::vector comp(n + 1); for (int i = 2; i < n; i++) { if (!comp[i]) ps.push_back(i); for (int j = 0; j < ps.size() && i * ps[j] < n; j++) { comp[i * ps[j]] = 1; if (i % ps[j] == 0) break; } } int ret = 0; for (auto p : ps) { auto t = p * p - 2; if (p > n || t > n) break; auto it = std::lower_bound(ps.begin(), ps.end(), t); if (it != ps.end() && *it == t) { if (t == p) ret++; else ret += 2; } } std::cout << ret << std::endl; return 0; }