let fn =
  fun arr ->
    arr
    |> Array.mapi (fun i x -> i, x)
    |> fun arri ->
      arri.[1..arr.Length - 2]
      |> Seq.fold (
        fun (c, ret) (i, x) ->
          (arr.[i - 1], arr.[i + 1])
          |> fun (p, n) -> c > 0 && ((x < p && x < n) || (x > p && x > n))
          |> fun sw -> if sw then (0, ret + 1) else (c + 1, ret)
      ) (0, 1)
  |> fun (_, ret) -> ret

stdin.ReadLine()
|> ignore
|> fun () -> stdin.ReadLine()
|> fun x -> x.Split(' ')
|> Array.map int
|> fun arr -> Array.concat [[| arr.[0] |]; arr; [| arr.[arr.Length - 1] |]]
|> fun arr -> [arr |> fn; arr |> Array.rev |> fn] |> Seq.min
|> printfn "%d"
