N=int(input()) if N==2:exit(print(1)) MOD=998244353 class matrix_mod: def __init__(self, data, mod:int=MOD): self._mat = data._mat if isinstance(data, self.__class__) else data self.row = len(data) self.col = len(data[0]) self.mod = mod @staticmethod def copy_m(m:list): return [[c for c in r] for r in m] @staticmethod def _mul(m1:list, m2:list, mod:int): return [[sum([(z1*z2)%mod for (z1,z2) in zip(x1,y2)])%mod for y2 in zip(*m2)] for x1 in m1] def mul(self, m:"matrix_mod"): assert self.col==m.row assert self.mod==m.mod return self.__class__(self.__class__._mul(self._mat, m._mat, self.mod), mod=self.mod) def __matmul__(self, other:"matrix_mod"): return self.mul(other) @classmethod def _pow(cls, m:list, n:int, mod:int): assert isinstance(n, int) assert n > 0 ret = None mm = cls.copy_m(m) while n: if n&1: if ret is None: ret = cls.copy_m(mm) else: ret = cls._mul(mm, ret, mod) mm = cls._mul(mm, mm, mod) n >>= 1 return ret def pow(self, n:int): assert self.row==self.col return self.__class__(self.__class__._pow(self._mat, n, self.mod), mod=self.mod) def __pow__(self, other:"matrix_mod"): print(other) return self.pow(other) m = matrix_mod([[1,1,0],[1,0,1],[0,0,1]], mod=MOD) m = m.pow(N-2) m2 = matrix_mod([[0],[1],[1]], mod=MOD) ans = matrix_mod([[1,1,0]], mod=MOD)@m @ m2 print(ans._mat[0][0])