#include using namespace std; int main() { int64_t n; cin >> n; vector ps; ps.emplace_back(2); for (int64_t i = 3; i <= n; i += 2) { bool f = true; for (auto &p : ps) { if (i < p * p) { break; } f &= i % p != 0; } if (f) { ps.emplace_back(i); } } int64_t ans = 0; for (auto &x : ps) { int64_t r = x * x; auto itr = lower_bound(ps.begin(), ps.end(), r - 2); if (itr != ps.end() && (*itr == r - 2)) { ans++; } } ans *= 2; ans--; cout << ans << endl; return 0; }