object Main extends App {

  sealed trait Property

  case object Up extends Property

  case object Down extends Property

  case object Keep extends Property

  @scala.annotation.tailrec
  def loop(head: Int, tail: List[Int], property: Property, count: Int): Int = {
    if (tail.isEmpty) {
      count
    } else {
      val x :: xs = tail
      if (property == Keep) {
        loop(x, xs, if (head == x) Keep else if (head < x) Up else Down, count)
      } else if ((property == Up && head <= x) || (property == Down && x <= head)) {
        loop(x, xs, property, count)
      } else {
        loop(x, xs, Keep, count + 1)
      }
    }
  }

  val sc = new java.util.Scanner(System.in)
  val x :: xs = List.fill(sc.nextInt())(sc.nextInt())
  println(loop(x, xs, Keep, 1))

}
