import sys input = sys.stdin.readline mod=998244353 N=int(input()) ANS=N+1+(1+N-1)*(N-1)//2*pow(3,mod-2,mod) print(ANS%mod)