use std::io::{read_to_string, stdin}; fn main() { let temp = read_to_string(stdin()).unwrap(); let mut iter = temp .split_ascii_whitespace() .map(|x| x.parse::().unwrap()); let (n, m) = (iter.next().unwrap(), iter.next().unwrap()); let mut cumf = 2 % m; let (mut f1, mut f2) = (1 % m, 1 % m); if n == 1 { println!("{}", f1); } else if n == 2 { println!("{}", cumf); } else { for _ in 3..=n { let newf = (f2 + f1) % m; cumf += newf; cumf %= m; f1 = f2; f2 = newf; } println!("{}", cumf); } }