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 n: usize = iter.next().unwrap().parse().unwrap(); let lengths = iter.rev() .map(|l| l.parse::().unwrap()); let mut search_num: usize = n; let mut count: usize = 0; for length in lengths { if length == search_num { count += 1; search_num -= 1; } } println!("{}", n - count); }