from typing import Sequence import numpy as np def mat_mul(mat1: np.matrix, mat2: np.matrix, mod: int = None): ans = mat1 * mat2 return ans if mod is None else ans % mod def mat_pow(mat1: Sequence[Sequence[int]], n: int, mod: int = None) -> Sequence[Sequence[int]]: mat1 = np.matrix(mat1) ans = np.identity(len(mat1)) while n > 0: if n & 1: ans = mat_mul(ans, mat1) mat1 = mat_mul(mat1, mat1) n >>= 1 return ans def main(): N = int(input()) MOD = 998244353 fib_matrix = np.matrix([[1, 1], [1, 0]]) init = np.array(([1, 0], )).T fib_matrix_pow = mat_pow(fib_matrix, N, MOD) fib_N = np.dot(fib_matrix_pow, init) print(int(fib_N[0, 0] - 1) % MOD) if __name__ == "__main__": main()