#include using ll = long long; using uint = unsigned int; using ull = unsigned long long; using ld = long double; template using max_heap = std::priority_queue; template using min_heap = std::priority_queue, std::greater>; constexpr int popcount(const ull v) { return v ? __builtin_popcountll(v) : 0; } constexpr int log2p1(const ull v) { return v ? 64 - __builtin_clzll(v) : 0; } constexpr int lsbp1(const ull v) { return __builtin_ffsll(v); } constexpr int clog(const ull v) { return v ? log2p1(v - 1) : 0; } constexpr ull ceil2(const ull v) { return 1ULL << clog(v); } constexpr ull floor2(const ull v) { return v ? (1ULL << (log2p1(v) - 1)) : 0ULL; } constexpr bool btest(const ull mask, const int ind) { return (mask >> ind) & 1ULL; } template bool chmin(T& a, const T& b) { return (a > b ? a = b, true : false); } template bool chmax(T& a, const T& b) { return (a < b ? a = b, true : false); } template constexpr T inf_v = std::numeric_limits::max() / 4; template constexpr Real pi_v = Real{3.141592653589793238462643383279502884}; template constexpr T TEN(const int n) { return n == 0 ? T{1} : TEN(n - 1) * T{10}; } template struct fix : F { fix(F&& f) : F{std::forward(f)} {} template auto operator()(Args&&... args) const { return F::operator()(*this, std::forward(args)...); } }; template auto nd_array(int const (&szs)[n], const T x = T{}) { if constexpr (i == n) { return x; } else { return std::vector(szs[i], nd_array(szs, x)); } } class printer { public: printer(std::ostream& os_ = std::cout) : m_os{os_} { m_os << std::fixed << std::setprecision(15); } template int ln(const Args&... args) { return dump(args...), m_os << '\n', 0; } template int el(const Args&... args) { return dump(args...), m_os << std::endl, 0; } private: template void dump(const T& v) { m_os << v; } template void dump(const std::vector& vs) { for (int i = 0; i < (int)vs.size(); i++) { m_os << (i ? " " : ""), dump(vs[i]); } } template void dump(const std::vector>& vss) { for (int i = 0; i < (int)vss.size(); i++) { m_os << (0 <= i or i + 1 < (int)vss.size() ? "\n" : ""), dump(vss[i]); } } template int dump(const T& v, const Args&... args) { return dump(v), m_os << ' ', dump(args...), 0; } std::ostream& m_os; }; printer out; class range { private: struct itr { itr(const int start = 0, const int step = 1) : m_cnt{start}, m_step{step} {} bool operator!=(const itr& it) const { return m_cnt != it.m_cnt; } int& operator*() { return m_cnt; } itr& operator++() { return m_cnt += m_step, *this; } int m_cnt, m_step; }; int m_start, m_end, m_step; public: range(const int start, const int end, const int step = 1) : m_start{start}, m_end{end}, m_step{step} { assert(m_step != 0); if (m_step > 0) { m_end = m_start + std::max(m_step - 1, m_end - m_start + m_step - 1) / m_step * m_step; } if (m_step < 0) { m_end = m_start - std::max(-m_step - 1, m_start - m_end - m_step - 1) / (-m_step) * (-m_step); } } itr begin() const { return itr{m_start, m_step}; } itr end() const { return itr{m_end, m_step}; } }; range rep(const int end, const int step = 1) { return range(0, end, step); } range per(const int rend, const int step = -1) { return range(rend - 1, -1, step); } class scanner { public: scanner(std::istream& is_ = std::cin) : m_is{is_} { m_is.tie(nullptr), std::ios::sync_with_stdio(false); } template T val() { T v; return m_is >> v, v; } template T val(const T offset) { return val() - offset; } template std::vector vec(const int n) { return make_v(n, [this]() { return val(); }); } template std::vector vec(const int n, const T offset) { return make_v(n, [this, offset]() { return val(offset); }); } template std::vector> vvec(const int n0, const int n1) { return make_v>(n0, [this, n1]() { return vec(n1); }); } template std::vector> vvec(const int n0, const int n1, const T offset) { return make_v>(n0, [this, n1, offset]() { return vec(n1, offset); }); } template auto tup() { return std::tuple...>{val()...}; } template auto tup(const Args&... offsets) { return std::tuple...>{val(offsets)...}; } private: template std::vector make_v(const int n, F f) { std::vector ans; for (int i = 0; i < n; i++) { ans.push_back(f()); } return ans; } std::istream& m_is; }; scanner in; template class prime_accum { public: prime_accum(const T N) : N{N}, SQRT{sqrt(N)}, isp(SQRT + 1, true) { assert(N >= 2); init(); init_smalls(); init_larges(); for (int i = 0; i < pn; i++) { const int p = ps[i]; for (int j = nn; (j--) > 0;) { const T n = ns[j]; if (n < (T)p * (T)p) { break; } const T pn = n / (T)p; const int pj = rev(pn); assert(C_smalls[p - 1] == i); Cs[j] -= Cs[pj] - C_smalls[p - 1]; Ss[j] -= (ST)p * (Ss[pj] - S_smalls[p - 1]); } } } T count(const T n) const { const int i = rev(n); assert(ns[i] == n); return Cs[i]; } ST sum(const T n) const { const int i = rev(n); assert(ns[i] == n); return Ss[i]; } private: static int sqrt(const T n) { int ans = std::sqrt(n); for (; (T)(ans + 1) * (T)(ans + 1) <= n; ans++) {} return ans; } void init() { isp[0] = false, isp[1] = false; for (int p = 2; p <= SQRT; p++) { if (not isp[p]) { continue; } ps.push_back(p); for (int q = p * 2; q <= SQRT; q += p) { isp[q] = false; } } for (T p = 1; p * p <= N; p++) { ns.push_back(p), ns.push_back(N / p); } std::sort(ns.begin(), ns.end()); ns.erase(std::unique(ns.begin(), ns.end()), ns.end()); pn = ps.size(), nn = ns.size(); } void init_smalls() { C_smalls.resize(SQRT + 1, 0), S_smalls.resize(SQRT + 1, 0); for (int n = 1; n <= SQRT; n++) { if (not isp[n]) { continue; } C_smalls[n] = isp[n] ? (T)1 : (T)0; S_smalls[n] = isp[n] ? (ST)n : (ST)0; } for (int n = 1; n <= SQRT; n++) { C_smalls[n] += C_smalls[n - 1], S_smalls[n] += S_smalls[n - 1]; } } void init_larges() { Cs.resize(nn, 0), Ss.resize(nn, 0); for (int i = 0; i < nn; i++) { const T n = ns[i]; Cs[i] = (T)n - (T)1; Ss[i] = (ST)n * (ST)(n + 1) / (ST)2 - (ST)2; } } int rev(const T n) const { return n <= SQRT ? (int)(n - 1) : nn - (int)(N / n); } T N = 0; const int SQRT; int pn, nn; std::vector isp; std::vector ps; std::vector ns; std::vector Cs; std::vector Ss; std::vector C_smalls; std::vector S_smalls; }; template inline bool miller_rabin(const T& n, const std::vector& as) { auto pow = [&](auto&& self, const V& a, const T k) -> V { if (k == 0) { return 1; } if (k % 2 == 0) { return self(self, (a * a) % V(n), k / 2); } else { return (self(self, a, k - 1) * a) % V(n); } }; T d = n - 1; for (; (d & 1) == 0; d >>= 1) {} for (const T& a : as) { if (n <= a) { break; } T s = d; V x = pow(pow, a, s); while (x != 1 and x != n - 1 and s != n - 1) { (x *= x) %= V(n); s *= 2; } if (x != n - 1 and s % 2 == 0) { return false; } } return true; } inline bool is_prime(const ull n) { if (n % 2 == 0) { return n == 2; } if (n < (1ULL << 32)) { return miller_rabin((uint)n, std::vector{2, 7, 61}); } else { return miller_rabin(n, std::vector{2, 325, 9375, 28178, 450775, 9780504}); } } constexpr int B = 100001; bool isp[B]; std::vector ps; int main() { std::fill(isp + 2, isp + B, true); for (const int p : range(2, B)) { if (not isp[p]) { continue; } ps.push_back(p); for (const int q : range(p + p, B, p)) { isp[q] = false; } } const auto N = in.val(); auto solve = [&](const ll N) { std::map cands; cands[1] = 1; std::map adds; int i = 0; for (const ll p : ps) { adds.clear(); for (const auto& [prod, num] : cands) { if (prod * (p - 1) > N) { break; } for (ll pr = prod * (p - 1); pr <= N; pr *= p) { adds[pr] += num; } } for (const auto& [p, n] : adds) { cands[p] += n; } if (adds.empty()) { break; } } prime_accum pi(N); ll ans = 0; for (const auto& [p, n] : cands) { ans += n; const ll pmax = N / p + 1; if (pmax < B) { continue; } const ll P = pi.count(pmax - 1) + is_prime(pmax) - (ll)ps.size(); ans += n * P; } return ans; }; out.ln(solve(N)); return 0; }