#include #include "atcoder/all" #define debug cout << "OK" << endl; template inline bool chmax(T& a, const T b) { if (a < b) { a = b; return true; } return false; } template inline bool chmin(T& a, const T b) { if (a > b) { a = b; return true; } return false; } inline int Code(char c) { if ('A' <= c and c <= 'Z')return (int)(c - 'A'); if ('a' <= c and c <= 'z')return (int)(c - 'a'); if ('0' <= c and c <= '9')return (int)(c - '0'); assert(false); } using namespace std; using namespace atcoder; #define int long long constexpr int MOD = 998244353; constexpr int INF = (1LL << 62); using minit = modint998244353; template ostream& operator << (ostream& st, const vector &v) { for (const T value : v) { st << value << " "; } return st; } template istream& operator >> (istream& st, vector& v) { for (T &value : v) { st >> value; } return st; } class Matrix { public: int mod = MOD; Matrix() {} Matrix(int x) { mat.resize(x); } Matrix(int x, int y) { mat.resize(x, vector(y)); } vector> mat; void Set(int x, int y, int value) { mat[x][y] = value; return; } void operator = (const Matrix& m) { mat = m.mat; return; } void operator = (const vector>& v) { mat = v; return; } bool operator == (const Matrix& m) { return mat == m.mat; } Matrix operator + (Matrix& m) { assert(mat.size() == m.mat.size()); assert(mat[0].size() == m.mat[0].size()); Matrix m2(mat.size(), mat[0].size()); for (int i = 0; i < mat.size(); i++) { for (int j = 0; j < mat[0].size(); j++) { m2.mat[i][j] = mat[i][j] + m.mat[i][j]; m2.mat[i][j] %= mod; } } return m2; } Matrix operator - (Matrix& m) { assert(mat.size() == m.mat.size()); assert(mat[0].size() == m.mat[0].size()); Matrix m2(mat.size(), mat[0].size()); for (int i = 0; i < mat.size(); i++) { for (int j = 0; j < mat[0].size(); j++) { m2.mat[i][j] = mat[i][j] - m.mat[i][j]; m2.mat[i][j] += mod; m2.mat[i][j] %= mod; } } return m2; } Matrix operator * (Matrix& m) { assert(mat[0].size() == m.mat.size()); Matrix m2(mat.size(), m.mat[0].size()); for (int i = 0; i < mat.size(); i++) { for (int j = 0; j < m.mat[0].size(); j++) { for (int k = 0; k < m.mat.size(); k++) { m2.mat[i][j] += (mat[i][k] * m.mat[k][j]) % mod; m2.mat[i][j] %= mod; } } } return m2; } Matrix pow(int a) { bool inited = false; Matrix ans; Matrix base = (*this); for (int i = 0; i < 63; i++) { if (a & (1ll << i)) { if (!inited) { ans = base; inited = true; } else ans = ans * base; } base = base * base; } return ans; } }; ostream& operator << (ostream& st, const Matrix& m) { for (const vector v : m.mat) { for (const int a : v) { cout << a << " "; } cout << endl; } return st; } void solve() { Matrix base(2, 2); base = { {1,1},{1,0} }; Matrix ot(2, 1); vector> p = { {1},{1} }; ot = p; int N; cin >> N; if (N == 1) { cout << 0 << endl; return; } Matrix ans = base.pow(N) * ot; cout << ans.mat[1][0] - 1 << endl; } signed main() { int T = 1; // cin >> T; for (int i = 0; i < T; i++) solve(); return 0; }