fn main() { let mut input = String::new(); std::io::Read::read_to_string(&mut std::io::stdin(), &mut input).ok(); let input: Vec = input .split_whitespace() .map(|n| n.parse().unwrap()) .collect(); let (mut fn0, mut fn1) = (0, 1); for _ in 2..input[0] { fn1 += std::mem::replace(&mut fn0, fn1); if fn1 >= input[1] { fn1 %= input[1]; } } println!("{}", fn1); }