import Control.Monad
import Data.List
sort' = sortBy (flip compare)
main = do
    n <- readLn
    ss <- (map ((map read) . words)) <$> replicateM 3 getLine
    print $ solve n ss
solve :: Int -> [[Int]] -> Int
solve n (a:b:c:d) = f (sort' a) (sort' b) (sort' c)
f a b c = sum (fmap g a) where
    g x = g1 (reverse(takeWhile (x<) b))
    g1 [] = 0
    g1 (x:xs) = let n = h c x in if n /= 0 then n + g1 xs else 0
    h [] _ = 0
    h (c:cs) x
        | (x < c) = 1 + h cs x
        | otherwise = 0