'use strict'

const main = arg => {
  arg = arg.trim().split("\n");

  const w = ~~(arg[0].split(" ")[0]);
  const h = ~~(arg[0].split(" ")[1]);
  const n = ~~(arg[0].split(" ")[2]);

  const points = arg.slice(1, n + 1).map(l => l.split(" ").map(n => ~~n));
  const list = [...Array(h)].map(l => [...Array(w)].fill(0));

  for(const point of points) {
    const x = point[0];
    const y = point[1];
    const a = point[2] - 1;

    const fromH = [0, 0, 0, y];
    const toH   = [h, h, y, h];
    const fromW = [0, x, 0, 0];
    const toW   = [x, w, w, w];

    for(let i = fromH[a]; i < toH[a]; i++) {
      for(let j = fromW[a]; j < toW[a]; j++) {
        list[i][j] = 1;
      }
    }
  }

  let cnt = 0;
  
  for(let i = 0; i < h; i++) {
    for(let j = 0; j < w; j++) {
      if(list[i][j] === 0) cnt++;
    }
  }

  console.log(cnt);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));
