import Control.Monad
import Data.List
sort' = sortBy (flip compare)
main :: IO ()
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 :: [Int] -> [Int] -> [Int] -> Int
f a b c = sum (fmap g a) where
    g x = sum (fmap (h c) (takeWhile (x<) b))
    h [] _ = 0
    h (c:cs) x
        | (x < c) = 1 + h cs x
        | otherwise = 0