#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;
typedef pair<int,int> pi;
typedef pair<lld,lld> pl;
typedef pair<int,lld> pil;
typedef pair<lld,int> pli;
typedef vector<int> vit;
typedef vector<vit> vitt;
typedef vector<lld> vlt;
typedef vector<vlt> vltt;
typedef vector<pi> vpit;
typedef vector<vpit> vpitt;
typedef long double ld;
#define x first
#define y second
#define pb push_back
#define all(v) v.begin(), v.end()
#define sz(x) (int)x.size()
#define mk(a,b) make_pair(a,b)
bool isrange(int y,int x,int n,int m){
	 if(0<=y&&y<n&&0<=x&&x<m) return true;
	 return false;
}
int dy[4] = {1,0,-1,0},dx[4]={0,1,0,-1},ddy[8] = {1,0,-1,0,1,1,-1,-1},ddx[8] = {0,1,0,-1,1,-1,1,-1};
const int MAX = 202020;
int vis1[MAX],vis2[MAX],seg[MAX*4],start = 1;
bool tmr(pi a,pi b){
	return a.x > b.x;
}
void upd(int x){
	x += start;
	seg[x]--;
	for(int e=(x/2);e>=1;e/=2) seg[e] = seg[e*2] + seg[e*2+1];
}
int getn(int l,int r){
	l += start;
	r += start;
	int ans = 0;
	while(l<=r){
		if(l&1) ans += seg[l++];
		if(!(r&1)) ans += seg[r--];
		l >>= 1;
		r >>= 1;
	}
	return ans;
}
int main(void){
	while(start<MAX) start *= 2;
	int n,m,que;
	scanf("%d%d%d",&n,&m,&que);
	for(int e=1;e<=n;e++){
		vis1[e] = m;
	}
	for(int e=1;e<=m;e++){
		vis2[e] = n;
	}
	while(que--){
		int y,x;
		scanf("%d%d",&y,&x);
		vis1[y] = min(vis1[y],x-1);
		vis2[x] = min(vis2[x],y-1);
	}
	lld ans = 0;
	vector<pi> v;
	for(int e=1;e<=vis1[1];e++){
		ans += vis2[e];
		v.push_back(mk(vis2[e],e));
	}
	sort(all(v),tmr);
	for(int e=start;e<2*start;e++) seg[e] = 1;
	for(int e=start-1;e>=1;e--) seg[e] = seg[e*2] + seg[e*2+1];
	int st = 0;
	for(int p=vis2[1];p>=1;p--){
		for(;st<sz(v)&&v[st].x>=p;st++) upd(v[st].y);
		ans += getn(1,vis1[p]);
	}
	printf("%lld",ans);
	return 0;
}

#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define DIV 1000000007 //10^9+7
#define INF LONG_MAX/3
#define bit(n) (1LL<<(n))

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


struct segtree {
	vector<long long> data;
	long long n;
	segtree(long long nin){
		n = pow( 2, ceil( log(nin) / log(2) ) );
		long long size = 2 * n - 1;
		this->data.resize(size, 0);
	}

	//API for update val
	void update(long long idx, long long val){
		update(idx, val, 0, 0, n);
	}

	long long update(long long idx, long long val, long long node_id, long long left, long long right){
		//if query idx is within range return val
		if( !( left <= idx && idx < right ) ){
			return data[node_id];
		}
		if( left + 1 < right ) {
			//when node range is not 1, get update children val and update node data
			long long mid = (left + right) / 2 ;
			long long L = update(idx, val, 2 * node_id + 1, left, mid);
			long long R = update(idx, val, 2 * node_id + 2, mid, right);
			data[node_id] = L + R;
		} else {
			//when node range is 1, update node data
			data[node_id] = data[node_id] + val;
		}
		return data[node_id];
	}
	
	//API for get value of [l, r)
	long long get(long long l, long long r){
		return get(l, r, 0, 0, n);
	}

	/*
	 *internaly used function
	 *query_l: query left range
	 *query_r: query right range
	 *node_id: node id of 
	 *node_l:  node left range 
	 *node_r:  node right range
	 */
	long long get(long long query_l, long long query_r, long long node_id, long long node_l, long long node_r){
		//query range is outside of node range: return INF
		if( query_r <= node_l || node_r <= query_l ){
			return 0;
		}
		//query range is within node range: return node val
		if( query_l <= node_l && node_r <= query_r ){
			return data[node_id];
		}
		long long mid = (node_l + node_r) / 2;
		long long L = get(query_l, query_r, 2 * node_id + 1, node_l, mid);
		long long R = get(query_l, query_r, 2 * node_id + 2, mid, node_r);
		return L + R;
	}
};

vector<ll> yvec[200005];


int main(){
	ll H, W, M;
	cin >> H >> W >> M;
	vector<ll>X(M);
	vector<ll>Y(M);
	ll maxx = W;
	ll maxy = H;

	segtree ysg(H+5);;

	rep(i, M) cin >> Y[i] >> X[i];
	rep(i, M) X[i]--;
	rep(i, M) Y[i]--;

	rep(i, M) {
		yvec[X[i]].push_back(Y[i]);
		if(Y[i] == 0) chmin(maxx, X[i]);
		if(X[i] == 0) chmin(maxy, Y[i]);
	}
	rep(i, W) sort(yvec[i].begin(), yvec[i].end());

	set<ll> ngy;
	rep(i, maxy) ysg.update(i, 1);
	ll ans = 0;

	for(ll y = maxy; y < H; y++) ngy.insert(y);


	for(ll x = 0; x < W; x++) {
		ll miny = H;
		if(x >= maxx) miny = 0;
		for(ll y: yvec[x]) {
			chmin(miny, y);
			if(!ngy.count(y)) {
				ngy.insert(y);
				ysg.update(y, -1);
			}
		}
		//cout << "x = " << x << " uekara " << miny << " yokokara " << ysg.get(miny, H) << endl;
		//上からいけるやつ
		ans += miny;

		//上からいけなくて横からいけるやつ
		ans += ysg.get(miny, H);
	}

	cout << ans << endl;

}
