fn main() { let mut nm = String::new(); std::io::stdin().read_line(&mut nm).ok(); let nm: Vec = nm.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); let n = nm[0]; let m = nm[1]; let mut fibs: Vec = vec![]; fibs.push(0); fibs.push(1 % m); for i in 2..n { fibs.push((fibs[i-2] + fibs[i-1]) % m); } println!("{}", fibs[n-1]); }