main = do
  n <- getLine
  top <- (map read . words) <$> getLine
  mid <- (map read . words) <$> getLine
  bot <- (map read . words) <$> getLine
  putStrLn .show $ solved top mid bot

solved:: [Int] -> [Int] -> [Int] -> Int
solved top mid bot = length [[x, y, z] | x <- top, y <- mid, z <- bot, x < y, y < z]