n = gets.to_i a_list = gets.split.map(&:to_i) count = a_list.length - a_list.index(n) - 1 a = n - 1 (a_list.index(n) - 1).downto(0) do |i| if a_list[i] != a count += 1 else a -= 1 end end puts count