#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using Int = long long; template ostream &operator<<(ostream &os, const pair &a) { return os << "(" << a.first << ", " << a.second << ")"; }; template void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; } template bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; } template bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; } // floor(sqrt(a)) long long floorSqrt(long long a) { long long b = a, x = 0, y = 0; for (int e = (63 - __builtin_clzll(a)) & ~1; e >= 0; e -= 2) { x <<= 1; y <<= 1; if (b >= (y | 1) << e) { b -= (y | 1) << e; x |= 1; y += 2; } } return x; } constexpr int LIM = 100'010; Int N; Int sqrtN; bool isPrime[LIM]; Int primesLen; Int primes[LIM]; Int small[LIM], large[LIM], large1[LIM]; Int SMALL[LIM], LARGE[LIM]; Int ans; Int get(Int n) { if (n <= sqrtN + 1) return small[n]; if (n <= N) { const Int l = N / n; if (n == N / l) return large[l]; } return large1[N / (n - 1)]; } int main() { for (; ~scanf("%lld", &N); ) { sqrtN = floorSqrt(N + 1); fill(isPrime + 2, isPrime + sqrtN + 1 + 1, true); fill(small, small + sqrtN + 1 + 1, 0); fill(large, large + sqrtN + 1, 0); fill(large1, large1 + sqrtN + 1, 0); fill(SMALL, SMALL + sqrtN + 1, 0); fill(LARGE, LARGE + sqrtN + 1, 0); primesLen = 0; for (Int n = 1; n <= sqrtN + 1; ++n) small[n] = n; for (Int l = 1; l <= sqrtN; ++l) large[l] = N / l; for (Int l = 1; l <= sqrtN; ++l) large1[l] = N / l + 1; for (Int p = 2; p <= sqrtN + 1; ++p) { if (isPrime[p]) { primes[primesLen++] = p; const Int p2 = p * p; for (Int n = p2; n <= sqrtN + 1; n += p) isPrime[n] = false; const Int g1 = small[p - 1]; for (Int l = 1; l <= sqrtN; ++l) { Int n = N / l + 1; if (n < p2) break; large1[l] -= (get(n / p) - g1); --n; if (n < p2) break; large[l] -= (get(n / p) - g1); } for (Int n = sqrtN + 1; n >= 1; --n) { if (n < p2) break; small[n] -= (small[n / p] - g1); } } } for (Int n = 1; n <= sqrtN + 1; ++n) small[n] -= 1; for (Int l = 1; l <= sqrtN; ++l) large[l] -= 1; for (Int l = 1; l <= sqrtN; ++l) large1[l] -= 1; // cerr<<"sqrtN = "<