#include using namespace std; typedef vector> Matrix; // 行列の乗算(mod) Matrix mat_mul(const Matrix &a, const Matrix &b, int64_t mod) { Matrix c(a.size(), vector(b[0].size())); for(int i = 0; i < a.size(); i++) { for(int k = 0; k < b.size(); k++) { for(int j = 0; j < b[0].size(); j++) { c[i][j] += a[i][k] * b[k][j]; c[i][j] %= mod; } } } return c; } // 行列の累乗(mod) Matrix mat_pow(Matrix a, int64_t n, int64_t mod) { Matrix b(a.size(), vector(a.size())); for(int i = 0; i < a.size(); i++) b[i][i] = 1; while(n > 0) { if(n & 1) b = mat_mul(b, a, mod); a = mat_mul(a, a, mod); n >>= 1; } return b; } int main() { int64_t n; cin >> n; const int64_t mod = 998244353; Matrix a = {{1, 1, 0, 0, 0}, {1, 0, 0, 0, 1}, {0, 0, 1, 1, 0}, {0, 1, 1, 1, 0}, {0, 0, 0, 0, 1}}; Matrix b = {{0}, {0}, {0}, {0}, {1}}; Matrix ans = mat_mul(mat_pow(a, n - 1, mod), b, mod); cout << (ans[0][0] + ans[1][0]) % mod << endl; return 0; }