import scala.io.{StdIn => in}

object Main extends App {

  val n = in.readLine.toInt
  val seq = in.readLine.split(" ").map(_.toInt)

  val p = seq(0)
  val ans = seq.tail./:(1, p, 0) { (acc, i) =>
    acc match {
      case (cnt, pre, sign) if (pre == i && 0 == sign) => (cnt, i, 0)
      case (cnt, pre, sign) if (pre < i && 0 == sign) => (cnt, i, 1)
      case (cnt, pre, sign) if (pre > i && 0 == sign) => (cnt, i, -1)
      case (cnt, pre, sign) if (pre == i && 0 < sign) => (cnt, i, 1)
      case (cnt, pre, sign) if (pre == i && 0 > sign) => (cnt, i, -1)
      case (cnt, pre, sign) if (pre < i && 0 < sign) => (cnt, i, 1)
      case (cnt, pre, sign) if (pre > i && 0 > sign) => (cnt, i, -1)
      case (cnt, pre, sign) => (cnt + 1, i, 0)
    }
  }._1

  println(ans)
}