main :: IO ()
main = do
    _ <- getLine
    a <- map read . words <$> getLine :: IO [Int]
    b <- map read . words <$> getLine :: IO [Int]
    c <- map read . words <$> getLine :: IO [Int]
    print $ sum [ 1 | ai <- a, bi <- b, ci <- c, ai < bi && bi < ci ]
