import scala.io.StdIn

object Main{
  def main(args: Array[String]){
    StdIn.readLine()
    val line = StdIn.readLine().split(" ").toList.map(_.toInt)

    bSort(List(), line, 0)
  }

  def bSort(sorted: List[Int], unsorted: List[Int], n: Int){
    if(unsorted.length == 0) println(n)
    else bSort(sorted :+ unsorted.min, unsorted.filterNot(_ == unsorted.min), n+1)
  }
}