import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = do
  solve <$> getl read <*> getl (map read . words) >>= print

solve :: Int -> [Int] -> Int
solve n xs = search 0 xs
  where
    cp x y z
      | x < y && y > z = True
      | x > y && y < z = True
      | otherwise = False
    search cnt (x:y:z:zs)
      | cp x y z = search (cnt+1) (z:zs)
      | otherwise = search cnt (y:z:zs)
    search cnt _ = cnt + 1

getl :: (String -> a) -> IO a
getl f = f <$> getLine
