object Main {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn.readLine
    val _ = readLine
    val datA = readLine.split(" ").map(_.toInt)

    val dirinit    = 0
    val dirunknown = 1
    val dirinc = 2
    val dirdec = 3
    def searchCutPoint(result: Int, dir: Int, border: Int, ls: List[Int]): Int = (dir, border, ls) match {
      case (_, _, Nil) => result + 1
      case (dir, _, ls) if (dir == dirinit) => searchCutPoint(result, dirunknown, ls.head, ls.tail)
      case (dir, border, ls) if (dir == dirunknown) => {
        if     (border == ls.head) searchCutPoint(result, dirunknown, ls.head, ls.tail)
        else if(border >  ls.head) searchCutPoint(result, dirdec, ls.head, ls.tail)
        else                       searchCutPoint(result, dirinc, ls.head, ls.tail)
      }
      case (dir, border, ls) if (dir == dirinc) => {
        if (border <= ls.head) searchCutPoint(result,     dirinc,     ls.head, ls.tail)
        else                   searchCutPoint(result + 1, dirunknown, ls.head, ls.tail)
      }
      case (dir, border, ls) if (dir == dirdec) => {
        if (border >= ls.head) searchCutPoint(result,     dirdec,     ls.head, ls.tail)
        else                   searchCutPoint(result + 1, dirunknown, ls.head, ls.tail)
      }
    }
    val ans = searchCutPoint(0, dirinit, 0, datA.toList)
    println(ans)
  }
}
