#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,m,obs_n;
const int N=2e5+5;
set<int>row[N],col[N];
int seg[4*N],a[N];

void update(int index,int data,int segindex,int l,int r)
{
    if(l==r){
        seg[segindex]=data;
        return ;
    }
    int mid=(l+r)/2;
    if(index<=mid){
        update(index,data,2*segindex+1,l,mid);
    }else{
        update(index,data,2*segindex+2,mid+1,r);
    }
    seg[segindex]=seg[2*segindex+1]+seg[2*segindex+2];
}

int query(int index,int l,int r,int ql,int qr)
{
    if(l>=ql && r<=qr)  return seg[index];
    if(l>qr || r<ql)    return 0;
    int mid=(l+r)/2;
    int q1=query(2*index+1,l,mid,ql,qr);
    int q2=query(2*index+2,mid+1,r,ql,qr);
    return q1+q2;
}

void buildtree(int l,int r,int index)
{
    if(l==r){
        seg[index]=a[l];
        return;
    }
    int mid=(l+r)/2;
    buildtree(l,mid,2*index+1);
    buildtree(mid+1,r,2*index+2);
    seg[index]=seg[2*index+1]+seg[2*index+2];
}

//1- based
void solve(){
	cin>>n>>m>>obs_n;
	for(int i=0;i<obs_n;i++){
		int u,v;cin>>u>>v;
		u--;v--;
		row[u].insert(v);
		col[v].insert(u);
	}
	int block_c=(row[0].empty()?m-1:(*row[0].begin()-1));
	for(int i=0;i<=block_c;i++)	a[i]=1;
	buildtree(0,m-1,0);

	int ans=block_c+1;
	int free_r=(col[0].empty()?n-1:(*col[0].begin()-1));
	for(auto x:row[0])	update(x,0,0,0,m-1);
		
	// cout<<ans<<"\n";
	for(int r=1;r<n;r++){
		for(auto x:row[r])	update(x,0,0,0,m-1);

		if(r<=free_r){
			int block_c=(row[r].empty()?m-1:(*row[r].begin()-1));
			// cout<<r<<" "<<block_c<<"\n";
			// cout<<query(0,0,m-1,block_c+1,m-1)<<"\n";
			if(block_c+1>m-1)	ans+=block_c+1;
			else				ans+=block_c+1+query(0,0,m-1,block_c+1,m-1);
		}else{
			ans+=query(0,0,m-1,0,m-1);
		}
		// cout<<ans<<"\n";
		
	}
	cout<<ans<<"\n";
}

main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    #ifndef ONLINE_JUDGE    
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout); 
    #endif
    solve();
}
#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;

}
