import Control.Monad
main :: IO ()
main = do
    n <- readLn
    ss <- (map ((map read) . words)) <$> replicateM 3 getLine
    print $ solve n ss
solve :: Int -> [[Int]] -> Int
solve n (ax:bx:cx:d) = sum (liftM3 f ax bx cx) where
    f a b c = fromEnum ((a < b) && (b < c))