#include using namespace std; int main() { int h, w, n; cin >> h >> w >> n; vector a(n), b(n); for(int i = 0; i < n; ++i) { cin >> a[i] >> b[i]; a[i]--, b[i]--; } vector> defects(h, vector(w)); for(int i = 0; i < n; ++i) defects[a[i]][b[i]] = 1; vector dp(w); long long ans = 0; for(int i = 0; i < h; ++i) { vector> x; for(int j = 0; j < w; ++j) { if(defects[i][j]) { dp[j] = 0; x.clear(); continue; } dp[j]++; int k = dp[j]; int t = 1; while(!x.empty()) { auto [l, w, s] = x.back(); if(l < k) break; t += w; x.pop_back(); } if(x.empty()) { x.push_back({k, t, k * t}); ans += k * t; } else { auto [l, w, s] = x.back(); x.push_back({k, t, s + k * t}); ans += s + k * t; } } } cout << ans << endl; }