let i_inp : unit -> int = fun () ->
  int_of_string (input_line stdin)

let i_inp_list : unit -> int list = fun () ->
  let inp_split = Str.split (Str.regexp " ") (input_line stdin) in
  List.map (fun x -> int_of_string x) (inp_split)
  
let () =
  let _ = i_inp () in
  let l = i_inp_list () in
  let rec loop l =
    match l with
      [] -> 0
    | p1 :: [] -> 0
    | p1 :: p2 :: [] -> 0
    | p1 :: p2 :: p3 :: l' ->
       if not ((p2 < p1 && p2 < p3) || (p1 < p2 && p3 < p2)) then
         1 + loop (p2 :: p3 :: l')
       else
         loop (p2 :: p3 :: l')
  in
  let n = loop l in
  print_int n;
  print_newline ()
    
