object Main extends App {
  val Array(w,h,n) = readLine.split(" ").map{_.toInt}
  val (x,y,a) = (1 to n).map{_ =>
    val Array(x_,y_,a_) = readLine.split(" ").map{_.toInt}
  	(x_,y_,a_)
  }.unzip3
  
  val color = Array.ofDim[Int](w,h)
  
  (0 until n).foreach{idx => a(idx) match {
    case 1 => for(i <- 0 until x(idx); j <- 0 until h) color(i)(j) = 1
    case 2 => for(i <- x(idx) until w; j <- 0 until h) color(i)(j) = 1
    case 3 => for(i <- 0 until w; j <- 0 until y(idx)) color(i)(j) = 1
    case 4 => for(i <- 0 until w; j <- y(idx) until h) color(i)(j) = 1
    case _ => 
  }}
  
  println((0 until w).map{i => color(i).count{_ == 0}}.sum)
}