N = gets.to_i as = gets.split.map(&:to_i) cnt = 0 n = N as.reverse.each do | i | if i == n cnt += 1 n -= 1 end end p N - cnt