from math import isqrt MOD = 998244353 N = int(input()) ans = 0 th = isqrt(N) for i in range(1, th + 1): ans += pow(N // i, i, MOD) ans %= MOD for i in range(1, 13): r = N // i l = max(th, N // (i + 1)) d = r - l if i == 1: ans += r - l else: ans += pow(i, l + 1, MOD) * (pow(i, d, MOD) - 1) * pow(i - 1, -1, MOD) ans %= MOD if l == th: break print(ans)