function Sub(grid, w, h, x, y, a) {
  for (var i = 0; i < h; i++) {
    for (var j = 0; j < w; j++) {
      if (a === 1 && j < x) {
        grid[i][j] = false;
      } else if (a === 2 && j >= x) {
        grid[i][j] = false;
      } else if (a === 3 && i < y) {
        grid[i][j] = false;
      } else if (a === 4 && i >= y) {
        grid[i][j] = false;
      }
    }
  }
  return grid;
}

function Main(input) {
  var inputs = input.split("\n");
  var w_h_n = inputs[0].split(" ").map(e => parseInt(e, 10));
  var grid = new Array(w_h_n[1]);
  for (var i = 0; i < w_h_n[1]; i++) {
    grid[i] = new Array(w_h_n[0]).fill(true);
  }
  var x_y_a;
  for (var i = 1; i <= w_h_n[2]; i++) {
    x_y_a = inputs[i].split(" ").map(e => parseInt(e, 10));
    Sub(grid, w_h_n[0], w_h_n[1], x_y_a[0], x_y_a[1], x_y_a[2]);
  }
  var sum = 0;
  for (var i = 0; i < w_h_n[1]; i++) {
    for (var j = 0; j < w_h_n[0]; j++) {
      sum += grid[i][j] === true ? 1:0;
    }
  }
  console.log(sum);
}

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