let n = int (stdin.ReadLine())
let mutable c = 0
stdin.ReadLine().Split() |> Array.map int |> Array.windowed 3 |> Array.iter (fun x -> if x.[1] = (Array.sort x |> Array.item 1) then c <- c + 1)
printfn "%d" c