#include #include #include using namespace std; using ll = long long; using pii = pair; using pll = pair; using vi = vector; using vl = vector; #define rep3(i, a, b, c) for (ll i = (a); i < (b); i += (c)) #define rep2(i, a, b) rep3(i, a, b, 1) #define rep1(i, n) rep2(i, 0, n) #define rep0(n) rep1(aaaaa, n) #define ov4(a, b, c, d, name, ...) name #define rep(...) ov4(__VA_ARGS__, rep3, rep2, rep1, rep0)(__VA_ARGS__) #define per(i, a, b) for (ll i = (a) - 1; i >= (b); i--) #define fore(e, v) for (auto &&e : v) #define all(a) begin(a), end(a) #define sz(a) (int)(size(a)) #define lb(v, x) (lower_bound(all(v), x) - begin(v)) #define eb emplace_back template bool chmin(T &a, const S &b) { return a > b ? a = b, 1 : 0; } template bool chmax(T &a, const S &b) { return a < b ? a = b, 1 : 0; } const int INF = 1e9 + 100; const ll INFL = 3e18 + 100; #define i128 __int128_t struct _ { _() { cin.tie(0)->sync_with_stdio(0), cout.tie(0); } } __; using mint = atcoder::modint998244353; int main() { ll N; cin >> N; vl m = {0, 0, 0, 1000001, 31623, 3982, 1001, 373, 178, 101, 64, 44, 32, 25, 20, 16, 14, 12, 11, 9, 8, 8, 7, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3}; auto lpow = [&](ll a, ll n) -> ll { ll res = 1; rep(n) res *= a; return res; }; vector prod3; prod3.reserve(accumulate(all(m), 0ll) + 10); rep(i, 3, 60) { rep(j, 2, m[i]) { prod3.push_back(pll{lpow(j, i), i}); } } prod3.push_back(pll{N + 1, INF}); sort(all(prod3)); vector krt(sz(m), 1); auto f = [&](ll n) -> mint { if (n <= 0) return mint(0); ll m = sqrt(n); if ((m + 1) * (m + 1) <= n) m += 1; mint p = m - 1, p2 = m; return (p * (p + 1) * (2 * p + 1) * (3 * p * p + 3 * p - 1) / 15 + 3 * (p * (p + 1) / 2).pow(2) + p * (p + 1) * (2 * p + 1) / 6) + p2 * (p2 * p2 + n) * (n - p2 * p2 + 1) / 2; }; ll l = 0; mint ans = 0, p = 1; rep(i, sz(prod3)) { ll r = prod3[i].first; ans += (f(r - 1) - f(l)) * p; // cerr << l << ' ' << r << ' ' << prod3[i].first << ' ' << prod3[i].second // << ' ' << p.val() << endl; if (prod3[i].second == INF) break; p /= krt[prod3[i].second]; krt[prod3[i].second] += 1; p *= krt[prod3[i].second]; l = r - 1; } cout << ans.val() << '\n'; }