#include <algorithm>
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
using namespace std;

using ll = long long;

const int MAX_H = 2e5;
const int MAX_W = 2e5;

// From https://cp-algorithms.com/data_structures/fenwick.html
struct FenwickTree {
   vector<int> bit;  // binary indexed tree
   int n;

   FenwickTree(int n) {
      this->n = n;
      bit.assign(n, 0);
   }

   FenwickTree(vector<int> a) : FenwickTree(a.size()) {
      for (size_t i = 0; i < a.size(); i++)
         add(i, a[i]);
   }

   int sum(int r) {
      int ret = 0;
      for (; r >= 0; r = (r & (r + 1)) - 1)
         ret += bit[r];
      return ret;
   }

   int sum(int l, int r) {
      return sum(r) - sum(l - 1);
   }

   void add(int idx, int delta) {
      for (; idx < n; idx = idx | (idx + 1))
         bit[idx] += delta;
   }

   void set(int idx, int val) {
      int curr = sum(idx, idx);
      if (curr == 1) add(idx, -1);
      add(idx, val);
   }
};

vector<int> byRow[MAX_H + 1], byCol[MAX_W + 1];

int main() {

   int h, w, m;
   scanf("%d %d %d", &h, &w, &m);
   for (int i = 0; i < m; i++) {
      int x, y;
      scanf("%d %d", &x, &y);
      byRow[x].push_back(y);
      byCol[y].push_back(x);
   }
   for (int i = 1; i <= h; i++) {
      byRow[i].push_back(w + 1);
      sort(byRow[i].begin(), byRow[i].end());
   }
   for (int i = 1; i <= w; i++) {
      byCol[i].push_back(h + 1);
      sort(byCol[i].begin(), byCol[i].end());
   }

   ll ans = 0;
   // Go right, then down
   for (int i = 1; i < byRow[1].front(); i++) {
      assert(byCol[i].front() > 1);
      ans += byCol[i].front() - 1;
   }

   FenwickTree blockedColumns(w + 1);
   // Go down, then right
   for (int i = 1; i < byCol[1].front(); i++) {
      assert(!byRow[i].empty());
      assert(byRow[i].front() > 1);

      // Add cells that in columns you can't reach by going right first
      ans += max(0, byRow[i].front() - byRow[1].front());

      // Add cells that are blocked from above
      ans += blockedColumns.sum(1, byRow[i].front() - 1);

      for (int blockedColumn : byRow[i]) {
         if (blockedColumn < byRow[1].front()) blockedColumns.set(blockedColumn, 1);
      }
   }
   printf("%lld\n", ans);

   return 0;
}


#include <bits/stdc++.h>


using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0; i<ll(n); i++)
#define FOR(i,m,n) for(ll i=ll(m); i<ll(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<ll,ll>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }

const ll  INF = (1 << 30) - 1;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;

VLL tate[200005];
VLL yoko[200005];
VLL cnt[200005];
struct Segment_tree {
	using T = ll;

	ll n;
	vector<T> data;
	const T out = 0LL;

	inline T vmerge(T l, T r) { return l + r; }

	Segment_tree(ll n) :n(n) { data.assign(2 * n, out); }

	void update(ll p, T x) {  // set value at position p
		for (data[p += n] = x; p > 1; p >>= 1) {
			data[p >> 1] = vmerge(data[p], data[p ^ 1]);
		}
	}

	T query(ll l, ll r) {  // sum on interval [l, r)
		T resl = out, resr = out;
		for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
			if (l & 1) resl = vmerge(data[l++], resl);
			if (r & 1) resr = vmerge(resr, data[--r]);
		}
		return vmerge(resl, resr);
	}
};


int main() {

	ll h, w, m;
	cin >> h >> w >> m;

	vector<pair<ll, ll>> v(m);
	REP(i, m) {
		cin >> v[i].first >> v[i].second;
		v[i].first--;
		v[i].second--;
		tate[v[i].first].push_back(v[i].second);
		yoko[v[i].second].push_back(v[i].first);
	}

	REP(i, 200005) {
		sort(ALL(tate[i]));
		sort(ALL(yoko[i]));
	}

	ll x;
	if (tate[0].size() == 0)x = w;
	else x = tate[0][0];

	ll ans = 0;

	

	REP(i, x) {
		if (yoko[i].size() == 0) {
			ans += h;
			cnt[h].push_back(i);
		}
		else {
			ans += yoko[i][0];
			cnt[yoko[i][0]].push_back(i);
		}
		//cerr << "   "<<ans << endl;
	}
	FOR(i, x, w) {
		cnt[0].push_back(i);
	}
	Segment_tree rsq(200005);

	cerr << ans << endl;
	


	ll y;
	if (yoko[0].size() == 0)y = h;
	else y = yoko[0][0];

	cerr << y << endl;
	

	FOR(i, 0, y) {
		if (tate[i].size() == 0) {
			ans += rsq.query(0, w);
		}
		else {
			ans += rsq.query(0, tate[i][0]);
		}
		for (ll j : cnt[i]) {
			//cerr << i << ' ' << j << endl;
			rsq.update(j, 1);
		}
	}
	cout << ans << endl;

}

