import Control.Applicative
import Data.List
import Control.Monad
strToInt s = (read :: String -> Int) s

main :: IO ()
main = do
    -- 整数の入力
    n <- getLine
    -- スペース区切り整数の入力
    as <- map strToInt . words <$> getLine
    bs <- map strToInt . words <$> getLine
    cs <- map strToInt . words <$> getLine
    -- 出力
    putStrLn . show $ solve as bs cs

solve :: [Int] -> [Int] -> [Int] -> Int
solve as bs cs = length [(a, b, c) | a <- as, b <- bs, c <- cs, a < b, b < c]
