var count: Int = 0

  for (a <- A) {
    var indexB: Int = 0
    while (indexB <= N && a < B(indexB)) {
      var indexC: Int = 0
      while (indexC <= N && B(indexB) < C(indexC)) {
        count = count + 1
        indexC = indexC + 1
      }
      indexB = indexB + 1
    }
  }

  println(count)
}