object Main extends App {
  var n = readLine.toInt
  var a = 0
  if (n >= 2) {
  	val in = readLine().split(" ").map(i => i.toInt)
  	while (in(n - 2) >= in(n - 1)) {
    	n -= 1
  		a += 1
  	}
  }
  println(a)
}