using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
namespace AtCoder {
    class MainClass {
        public static void Main(string[] args) { new MainClass().solve(); }

        Scanner cin = new Scanner();

        int W, H, N;
        int[] x, y, a;
        void solve() {
            W = cin.nextInt();
            H = cin.nextInt();
            N = cin.nextInt();
            x = new int[N];
            y = new int[N];
            a = new int[N];
            for (int i = 0; i < N; i++) {
                x[i] = cin.nextInt();
                y[i] = cin.nextInt();
                a[i] = cin.nextInt();
                x[i]--;
                y[i]--;
            }

            int[,] map = new int[H,W];

            for (int i = 0; i < N; i++) {
                switch (a[i]) {
                    case 1:
                        for (int j = 0; j < H; j++)
                            for (int k = 0; k <= x[i]; k++)
                                map[j, k] = 1;
                        break;
                    case 2:
                        for (int j = 0; j < H; j++)
                            for (int k = x[i]+1; k < W; k++)
                                map[j, k] = 1;
                        break;
                    case 3:
                        for (int j = 0; j <= y[i]; j++)
                            for (int k = 0; k < W; k++)
                                map[j, k] = 1;
                        break;
                    case 4:
                        for (int j = y[i]+1; j < H; j++)
                            for (int k = 0; k < W; k++)
                                map[j, k] = 1;
                        break;
                    default :
                        break;
                }
            }

            int ans = 0;

            for (int i = 0; i < map.GetLength(0);i++)
                for (int j = 0; j < map.GetLength(1);j++)
                if (map[i, j] == 0) 
                        ans++;
                       
            Console.WriteLine(ans);

        }
        class Scanner {
            string[] nextBuffer; int BufferCnt; char[] cs = new char[] { ' ' };
            public Scanner() { nextBuffer = new string[0]; BufferCnt = 0; }
            public string next() {
                if (BufferCnt < nextBuffer.Length) return nextBuffer[BufferCnt++];
                string st = Console.ReadLine();
                while (st == "") st = Console.ReadLine();
                nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
                BufferCnt = 0;
                return nextBuffer[BufferCnt++];
            }
            public int nextInt() { return int.Parse(next()); }
            public long nextLong() { return long.Parse(next()); }
            public double nextDouble() { return double.Parse(next()); }
        }
        class Mathf {
            private int mod = 1000000007;//10^9+7
            public int Mod { get; set; }
            public Mathf() { }
            public Mathf(int mod) { this.mod = mod; }
            public long Pow(long a, long b) {
                if (b == 0) return 1;
                if (b % 2 == 1) return (a % mod * Pow(a % mod, b - 1) % mod) % mod;
                else return Pow(a * a % mod, b / 2) % mod;
            }
            public long Fact(long n) { return n != 0 ? (n % mod * (Fact(n - 1) % mod) % mod) : 1; }
            public long C(long n, long r) {
                if (r == 0 || n == r) return 1;
                else return (Fact(n) % mod * Pow((Fact(n - r) % mod * Fact(r) % mod) % mod, mod - 2) % mod) % mod;
            }
        }
    }
}

Measured memory_bytes: 13220