#include<bits/stdc++.h>
using namespace std;
long long a,b,c;
long long ans;
int g[10000][3];
int ge = 0;
void find(int d,int e,int f) {
for(int j = 1;j <= ge;j++) {
if(g[ge][0] == d and g[ge][1] == e) {
if(g[ge][2] != 0 and f == 0) {
g[ge][2] = 0;
ans++;
}
if(g[ge][2] == 0 and f != 0) {
g[ge][2] = f;
ans--;
}
return;
}
}
if(f == 0)return;
ge++;
ans--;
g[ge][0] = d;
g[ge][1] = e;
g[ge][2] = f;
}
int main() {
cin>>a>>b>>c;
ans = a * b;
for(int i = 1;i <= c;i++) {
int d,e,f;
cin>>d>>e>>f;
find(d,e,f);
}
cout<<ans;
}