object Main extends App {
  val N: Int = io.StdIn.readInt() - 1

  val A: Seq[Int] = io.StdIn.readLine().split(" ").map(_.toInt).sortWith(_ < _)
  val B: Seq[Int] = io.StdIn.readLine().split(" ").map(_.toInt).sortWith(_ < _)
  val C: Seq[Int] = io.StdIn.readLine().split(" ").map(_.toInt).sortWith(_ < _)

  def ARec(i: Int, largerCount: Int): Int = {
    A.foldLeft(0)((res, cur) => {
      res + BRec(0, largerCount, cur)
    })
  }

  def BRec(i: Int, largerCount: Int, compared: Int): Int = {
    B.foldLeft(0)((res, cur) => {
      if (compared < cur) res + CRec(0, res, cur) else res
    })
  }

  def CRec(i: Int, largerCount: Int, compared: Int): Int = {
    C.foldLeft(0)((res, cur) => {
      if (compared < cur) res + 1 else res
    })
  }

  println(ARec(0, 0))
}