N = gets.to_i A = gets.split.map(&:to_i).reverse ans = 0 A.inject(N) do |x, v| if x == v x - 1 else ans += 1 x end end puts ans