#include <bits/stdc++.h>
#define int long long
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef __int128 LLL;
typedef std::pair<int, int> pii;
typedef std::pair<LL, int> pli;
typedef std::pair<LL, LL> pll;
#define fi first
#define se second
#define MP std::make_pair
LL read() {
LL s = 0; int f = 1;
char c = getchar();
while (!(c >= '0' && c <= '9'))
f ^= (c == '-'), c = getchar();
while (c >= '0' && c <= '9')
s = s * 10 + (c ^ 48), c = getchar();
return f ? s : -s;
}
const LL INF = 0x3f3f3f3f3f3f3f3fll;
const int N = 4e5 + 7, MOD = 998244353;
template<typename T> T& Fmax(T& x, T y) { return x = x < y ? y : x; };
template<typename T> T& Fmin(T& x, T y) { return x = x < y ? x : y; };
auto fplus = [](LL x, LL y) { return x + y < MOD ? x + y : x + y - MOD; };
auto fminus = [](LL x, LL y) { return x < y ? x - y + MOD : x - y; };
auto Fplus = [](LL &x, LL y) { x = fplus(x, y); };
auto Fminus = [](LL &x, LL y) { x = fminus(x, y); };
LL fpow(LL x, LL y = MOD - 2) {
LL ans = 1;
for (; y; x = x * x % MOD, y >>= 1)
if (y & 1) ans = ans * x % MOD;
return ans;
}
bool isp[N];
LL n, m, tot, pr[N], f[2][N], ans = 1;
LL id(LL x, LL y) { return x ? n / y : y; }
pll ID(LL x) { return x <= m ? MP(0, x) : MP(1, n / x); }
void Euler(int x) {
memset(isp, 1, sizeof(isp));
for (int i = 2; i <= x; i ++) {
if (isp[i]) pr[++ tot] = i;
for (int j = 1; j <= tot && i * pr[j] <= x; j ++) {
isp[i * pr[j]] = false;
if (i % pr[j] == 0) break;
}
}
}
int main() {
n = read(), Euler(m = sqrt(n));
for (int i = 0; i <= 1; i ++)
for (int j = 1; j <= m; j ++) f[i][j] = n / id(i, j) - 1;
for (int i = 1; i <= tot; i ++) {
LL lim = n / (pr[i] * pr[i]);
for (int j = 1; j <= m && id(0, j) <= lim; j ++) {
pll t = ID(id(0, j) * pr[i]);
f[0][j] += i - 1 - f[t.fi][t.se];
}
for (int j = m; j && id(1, j) <= lim; j --) {
pll t = ID(id(1, j) * pr[i]);
f[1][j] += i - 1 - f[t.fi][t.se];
}
}
for (LL l = 1, r, k; l <= n / 3; l = r + 1) {
r = n / (n / l), k = n / l;
pll t = ID(l); LL c = f[t.fi][t.se];
if (l * 2 <= n) t = ID(l * 2), c -= f[t.fi][t.se];
LL f = (k == 3 ? 3 : fpow(k, c) * (k - c - 1) % MOD);
ans = ans * fpow(f, r - l + 1) % MOD;
// std::cout << l << ' ' << r << ' ' << k << ' ' << c << ' ' << f << ' ' << ans << '\n';
}
std::cout << ans << '\n';
return 0;
}