import scala.io.StdIn

object Main extends App {

  val n = StdIn.readLine().toInt
  val ra = StdIn.readLine().split(' ').map(_.toInt)
  val rb = StdIn.readLine().split(' ').map(_.toInt)
  val rc = StdIn.readLine().split(' ').map(_.toInt)
  
  var count = 0
  (0 until n).foreach { a =>
    (0 until n).foreach { b =>
      if(ra(a) < rb(b)){
        (0 until n).foreach { c =>
          if(ra(a) < rb(b) && rb(b) < rc(c)){
            //println(ra(a) + " " + rb(b) + " " + rc(c))
            count += 1
          }
        }
      }
    }
  }

  println(count)

}