use std::io::Read; fn main() { let mut buf = String::new(); std::io::stdin().read_to_string(&mut buf).unwrap(); let mut iter = buf.split_whitespace(); let mut n: usize = iter.next().unwrap().parse().unwrap(); let lengths = iter.rev() .map(|l| l.parse::().unwrap()); for length in lengths { if length == n { n -= 1; } } println!("{}", n); }