import Data.List (sort)

main :: IO ()
main = do
  _ <- read <$> getLine :: IO Int
  as <- sort.map read.words <$> getLine :: IO [Int]
  bs <- sort.map read.words <$> getLine :: IO [Int]
  cs <- sort.map read.words <$> getLine :: IO [Int]
  print $ length [ () | a<-as, b<-bs, a<b, c<-cs, b<c ]
