#![allow(non_snake_case, unused_imports, unused_must_use)] use std::io::{self, prelude::*}; use std::str; const MOD: usize = 998_244_353; fn main() { let (stdin, stdout) = (io::stdin(), io::stdout()); let mut scan = Scanner::new(stdin.lock()); let mut out = io::BufWriter::new(stdout.lock()); macro_rules! input { ($T: ty) => { scan.token::<$T>() }; ($T: ty, $N: expr) => { (0..$N).map(|_| scan.token::<$T>()).collect::>() }; } let N = input!(usize); let mut c0 = 1; let mut c1 = 0; let d = |a: &Vec>, b: &Vec>| { let a11 = a[0][0]; let a12 = a[0][1]; let a21 = a[1][0]; let a22 = a[1][1]; let b11 = b[0][0]; let b12 = b[0][1]; let b21 = b[1][0]; let b22 = b[1][1]; return vec![ vec![(a11 * b11 + a12 * b21) % MOD, (a11 * b12 + a12 * b22) % MOD], vec![(a21 * b11 + a22 * b12) % MOD, (a21 * b12 + a22 * b22) % MOD], ]; }; let mut A = vec![vec![1, 1], vec![1, 0]]; let P = N - 1; let mut Q = vec![vec![1, 0], vec![0, 1]]; for i in 0..61 { if (P >> i) & 1 == 1 { Q = d(&Q, &A); } A = d(&A, &A); } // for _ in 2..N { // A = d(&A, &A_0); // } let mut cn0 = c0 * Q[0][0] + c1 * Q[0][1]; cn0 %= MOD; let mut cn1 = c0 * Q[1][0] + c1 * Q[1][1]; cn1 %= MOD; c0 = cn0; c1 = cn1; writeln!(out, "{}", c0 + c1 - 1); // for _ in 1..N { // let cn0 = c0 + c1; // let cn1 = c0; // c0 = cn0 % MOD; // c1 = cn1 % MOD; // writeln!(out, "{} {} {}", c0, c1, c0 + c1 - 1); // } } struct Scanner { reader: R, buf_str: Vec, buf_iter: str::SplitWhitespace<'static>, } impl Scanner { fn new(reader: R) -> Self { Self { reader, buf_str: vec![], buf_iter: "".split_whitespace(), } } fn token(&mut self) -> T { loop { if let Some(token) = self.buf_iter.next() { return token.parse().ok().expect("Failed parse"); } self.buf_str.clear(); self.reader .read_until(b'\n', &mut self.buf_str) .expect("Failed read"); self.buf_iter = unsafe { let slice = str::from_utf8_unchecked(&self.buf_str); std::mem::transmute(slice.split_whitespace()) } } } }