#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define rep(i, n) for(int i = 0; i < (n); i++) #define per(i, n) for(int i = (n) - 1; i >= 0; i--) using ll = long long; #define vi vector #define vvi vector #define vl vector #define pii pair #define pll pair #define all(a) (a).begin(), (a).end() #define rall(a) (a).rbegin(), (a).rend() constexpr int mod = 998244353; using namespace std; template bool chmax(T &a, const U &b){ return a < b ? (a = b, 1) : 0; } template bool chmin(T &a, const U &b){ return a > b ? (a = b, 1) : 0; } template struct Mint { ll x; constexpr Mint(ll x = 0) : x((x + mod) % mod){} static constexpr int get_mod(){ return mod; } constexpr Mint operator-() const{ return Mint(-x); } constexpr Mint operator+=(const Mint &a){ if((x += a.x) >= mod) x -= mod; return *this; } constexpr Mint &operator++(){ if(++x == mod) x = 0; return *this; } constexpr Mint operator++(int){ Mint temp = *this; if(++x == mod) x = 0; return temp; } constexpr Mint &operator-=(const Mint &a){ if((x -= a.x) < 0) x += mod; return *this; } constexpr Mint &operator--(){ if(--x < 0) x += mod; return *this; } constexpr Mint operator--(int){ Mint temp = *this; if(--x < 0) x += mod; return temp; } constexpr Mint &operator*=(const Mint &a){ (x *= a.x) %= mod; return *this; } constexpr Mint operator+(const Mint &a) const{ return Mint(*this) += a; } constexpr Mint operator-(const Mint &a) const{ return Mint(*this) -= a; } constexpr Mint operator*(const Mint &a) const{ return Mint(*this) *= a; } constexpr Mint pow(ll t) const{ if(!t) return 1; Mint res = 1, v = *this; while(t){ if(t & 1) res *= v; v *= v; t >>= 1; } return res; } constexpr Mint inv() const{ return pow(mod - 2); } constexpr Mint &operator/=(const Mint &a){ return (*this) *= a.inv(); } constexpr Mint operator/(const Mint &a) const{ return Mint(*this) /= a; } constexpr bool operator==(const Mint &a) const{ return x == a.x; } constexpr bool operator!=(const Mint &a) const{ return x != a.x; } constexpr bool operator<(const Mint &a) const{ return x < a.x; } constexpr bool operator>(const Mint &a) const{ return x > a.x; } friend istream &operator>>(istream &is, Mint &a){ return is >> a.x; } friend ostream &operator<<(ostream &os, const Mint &a){ return os << a.x; } }; using mint = Mint; template struct matrix { int n,m; private: vector> a; public: matrix(int n) : n(n), m(n), a(n, vector(n)){} matrix(int n, int m) : n(n), m(m), a(n, vector(m)){} matrix(const vector> &d) : a(d), n(d.size()), m(d[0].size()){} vector &operator[](const int &i){ return a[i]; } matrix &operator*=(const matrix &b){ assert(m == b.n); vector> c(n, vector(b.m)); for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) for(int k = 0; k < b.m; k++){ c[i][k] += a[i][j] * b.a[j][k]; } a = c; return *this; } matrix &operator+=(const matrix &b){ assert(n == b.n && m == b.m); for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) a[i][j] += b.a[i][j]; return *this; } matrix &operator-=(const matrix &b){ assert(n == b.n && m == b.m); for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) a[i][j] -= b.a[i][j]; return *this; } matrix operator*(const matrix &b) const{ return matrix(*this) *= b; } matrix operator+(const matrix &b) const{ return matrix(*this) += b; } matrix operator-(const matrix &b) const{ return matrix(*this) -= b; } matrix pow(ll t) const{ assert(n == m); matrix b(n), c = *this; for(int i = 0; i < n; i++) b[i][i] = 1; while(t > 0){ if(t & 1) b *= c; c *= c; t >>= 1; } return b; } T det() const{ assert(n == m); matrix b = *this; T res(1); bool flip = false; for(int i = 0; i < n; i++){ for(int j = i + 1; j < n; j++){ while(b[j][i] > 0){ swap(b[i], b[j]); flip ^= 1; const T d = b[j][i] / b[i][i]; for(int k = i; k < n; k++){ b[j][k] -= b[i][k] * d; } } } if(b[i][i] == 0) return 0; res *= b[i][i]; } if(flip) res = -res; return res; } matrix inv(){ assert(n == m); matrix b(n), c = *this; for(int i = 0; i < n; i++) b[i][i] = 1; int r = 0; for(int i = 0; i < n && r < n; i++){ if(c[r][i] == 0){ T max_val = 0; int mx_pos; for(int j = r+1; j < n; j++){ if(max_val < c[j][i]) max_val = c[j][i], mx_pos = j; } if(max_val == 0) return false; swap(c[r], c[mx_pos]); swap(b[r], b[mx_pos]); } T d = T(1) / c[r][i]; for(int j = 0; j < n; j++) c[r][j] *= d, b[r][j] *= d; for(int j = 0; j < n; j++){ T v = c[j][i]; if(j == r || c[j][i] == 0) continue; for(int k = 0; k < n; k++){ c[j][k] -= c[r][k] * v; b[j][k] -= b[r][k] * v; } } r++; } return b; } int size() const{ return n; } void debug(){ for(int i = 0; i < n; i++){ for(int j = 0; j < n; j++) cerr << a[i][j] << " "; cerr << "\n"; } } }; int main(){ ll n; cin >> n; matrix mat({ { 1, 1 }, { 1, 0 }, }); mat = mat.pow(n-1); mat.debug(); cout << mat[0][0] + mat[1][0] - 1 << "\n"; }