#include using namespace std; #ifdef _RUTHEN #include #else #define show(...) true #endif using ll = long long; #define rep(i, n) for (int i = 0; i < (n); i++) template using V = vector; #include using mint = atcoder::modint998244353; ostream &operator<<(ostream &os, const mint &p) { return os << p.val(); } template struct static_matrix { std::array, n> A; static_matrix() : A{{}} {} static_matrix(T val) : A{{}} { for (int i = 0; i < (int)n; i++) A[i].fill(val); } size_t size() const { return n; } int row() const { return (int)n; } int col() const { return (int)m; } inline const std::array &operator[](int i) const { return A[i]; } // read inline std::array &operator[](int i) { return A[i]; } // write static static_matrix E() { assert(n == m); static_matrix ret; for (int i = 0; i < (int)n; i++) ret[i][i] = T(1); return ret; } static_matrix &operator+=(const static_matrix &B) { int N = row(), M = col(); assert(N == B.row() && M == B.col()); for (int i = 0; i < N; i++) { for (int j = 0; j < M; j++) { (*this)[i][j] += B[i][j]; } } return (*this); } static_matrix &operator-=(const static_matrix &B) { int N = row(), M = col(); assert(N == B.row() && M == B.col()); for (int i = 0; i < N; i++) { for (int j = 0; j < M; j++) { (*this)[i][j] -= B[i][j]; } } return (*this); } static_matrix &operator*=(const static_matrix &B) { int N = row(), M = B.col(), L = B.row(); assert(L == col()); static_matrix C; for (int i = 0; i < N; i++) { for (int k = 0; k < L; k++) { for (int j = 0; j < M; j++) { C[i][j] += (*this)[i][k] * B[k][j]; } } } A.swap(C.A); return (*this); } static_matrix pow(long long k) { assert(row() == col()); static_matrix B = static_matrix::E(), X = (*this); while (k) { if (k & 1) B *= X; X *= X; k >>= 1; } A.swap(B.A); return (*this); } static_matrix operator+(const static_matrix &B) { return ((*this) += B); } static_matrix operator-(const static_matrix &B) { return ((*this) -= B); } static_matrix operator*(const static_matrix &B) { return ((*this) *= B); } friend std::ostream &operator<<(std::ostream &os, static_matrix &A) { int N = A.row(), M = A.col(); for (int i = 0; i < N; i++) { os << '['; for (int j = 0; j < M; j++) os << A[i][j] << " \n"[j == M - 1]; } return (os); } static_matrix &operator+=(const T &k) { int N = row(), M = col(); for (int i = 0; i < N; i++) for (int j = 0; j < M; j++) (*this)[i][j] += k; return (*this); } static_matrix &operator-=(const T &k) { int N = row(), M = col(); for (int i = 0; i < N; i++) for (int j = 0; j < M; j++) (*this)[i][j] -= k; return (*this); } static_matrix &operator*=(const T &k) { int N = row(), M = col(); for (int i = 0; i < N; i++) for (int j = 0; j < M; j++) (*this)[i][j] *= k; return (*this); } static_matrix &operator/=(const T &k) { int N = row(), M = col(); for (int i = 0; i < N; i++) for (int j = 0; j < M; j++) (*this)[i][j] /= k; return (*this); } static_matrix operator+(const T &k) { return ((*this) += k); } static_matrix operator-(const T &k) { return ((*this) -= k); } static_matrix operator*(const T &k) { return ((*this) *= k); } static_matrix operator/(const T &k) { return ((*this) /= k); } }; /** * @brief Static Matrix (行列, サイズ固定) * @docs docs/data_structure/static_matrix.md */ int main() { ios::sync_with_stdio(false); cin.tie(0); ll N; cin >> N; static_matrix dp; dp[0][0] = dp[0][1] = dp[1][0] = 1; dp = dp.pow(N - 1); mint ans = dp[0][0] + dp[1][0] - 1; cout << ans << '\n'; return 0; }