import Data.List
main :: IO()
main = do
  ps <- map read . words <$> getLine
  print $ slv ps 0
 
slv :: [Integer] -> Integer -> Integer
slv (p1:p2:p3:ps) ret | sec == p2 = slv (p2:p3:ps) (ret + 1)
                      | otherwise = slv (p2:p3:ps) ret
  where sec = (sort [p1, p2, p3]) !! 1
slv _ ret = ret