#include<stdio.h>
#include<iostream>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<iterator>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<int, int> p;
map<int, vector<p> > track;
int n, m, k;
int main()
{
scanf("%d%d%d", &n, &m, &k);
ll ans = (ll)n * m;
int row, left, right;
for(int i = 0; i < k; i++){
scanf("%d%d%d", &row, &left, &right);
track[row].push_back(p(left, right));
}
map<int, vector<p> >::iterator iter = track.begin();
int cnt = 0;
while(iter != track.end()){
vector<p> V = iter->second;
sort(V.begin(), V.end());
for(int i = 0; i < V.size(); ){
int j = i;
int r = V[j].second;
while(j < V.size() && V[j].first <= r + 1){
r = max(r, V[j].second); j++;
}
ans -= (r - V[i].first + 1);
i = j;
}
iter++;
}
printf("%lld", ans);
return 0;
}