import scala.io.{StdIn => in}
import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock

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) { case ((acc, pre, sign), i) =>
    acc match {
      case acc if (pre == i && 0 == sign) => (acc, i, 0)
      case acc if (pre < i && 0 == sign) => (acc, i, 1)
      case acc if (pre > i && 0 == sign) => (acc, i, -1)
      case acc if (pre == i && 0 < sign) => (acc, i, 1)
      case acc if (pre == i && 0 > sign) => (acc, i, -1)
      case acc if (pre < i && 0 < sign) => (acc, i, 1)
      case acc if (pre > i && 0 > sign) => (acc, i, -1)
      case _ => (acc + 1, i, 0)
    }
  }._1

  println(ans)
}