#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define reps(i,s,n) for(int i=s; i<n; i++)
#define per(i,n) for(int i=n-1; i>=0; i--)
#define pers(i,n,s) for(int i=n-1; i>=s; i--)
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define pb push_back
#define si(v) int(v.size())
#define lb(v,n) lower_bound(all(v),n)
#define lbi(v,n) lower_bound(all(v),n) - v.begin()
#define ub(v,n) upper_bound(all(v),n)
#define ubi(v,n) upper_bound(all(v),n) - v.begin()
 
#define mod 1000000007
#define infi 1010000000
#define infl 1100000000000000000
 
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define IN(n,m,v) rep(i,n) rep(j,m){cin >> v[i][j];}
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define cYES cout << "YES" << endl
#define cNO cout << "NO" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
 
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vs = vector<string>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}



template <typename T>
class BIT {
    ve<T> node;
    int n;
    
    T find(int m){
        T s = 0;
        while (m > 0) {
            s += node[m];
            m -= (m & (-m));
        }
        return s;
    }
    
public:
    BIT(int _n) : n(_n){
        node.assign(n+1,0LL);
    }
    
    T sum(int a, int b){
        T s_a = find(a);
        T s_b = find(b);
        return s_b - s_a;
    }
    
    
    void update(int m, T x){
        m++;
        while (m <= n) {
            node[m] += x;
            m += (m & (-m));
        }
    }
    
};




void solve(){
        
    int H,W,M;
    cin >> H >> W >> M;
    
    vl A(H,W),B(W,H);
    rep(i,M){
        ll h,w;
        cin >> h >> w;
        h--,w--;
        chmin(A[h],w);
        chmin(B[w],h);
    }
    ll ans = 1;
    reps(i,1,H) {
        if(A[i] == 0) break;
        ans += A[i];
    }
    reps(i,1,W){
        if(B[i] == 0) break;
        ans += B[i];
    }
    
    
    ve<pll> C;
    reps(i,1,H){
        if(A[i] == 0) break;
        C.pb({A[i],i});
    }
    sort(all(C));
    ll s = 1;
    
    
    
    BIT<ll> bi(H+10);
    rep(i,si(C)){
        pll p = C[i];
        if(p.fi == 0) continue;
        while (s < p.fi) {
            if(B[s] == 0) break;
            bi.update(B[s],1LL);
            s++;
        }
        //cout << p.fi csp p.se csp bi.sum(p.se,H+10) << endl;
        ans -= bi.sum(p.se,H+2);
    }
    
    cout << ans << endl;
    
}



int main(){
    
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    solve();

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define int long long
int h,w,m;
int mh=9999999,ml=9999999;
int blockx[200001],blocky[200001];
int xw[200001],yw[200001];
int a[1000001];
struct node
{
	int val,pos;
}ww[200001]; 
void add(int x,int v)
{
	while(x<=200000)
	{
		a[x]+=v;
		x+=x&-x;
	}
}
int find(int x)
{
	int answw=0;
	while(x)
	{
		answw+=a[x];
		x-=x&-x;
	}
	return answw;
}
bool cmp(node x,node y)
{
	return x.val<y.val;
}
signed main()
{
	cin>>h>>w>>m;
	ml=w;mh=h;
	for(int i=1;i<=m;i++)
	{
		cin>>blockx[i]>>blocky[i];
		if(blockx[i]==1)
		{
			ml=min(ml,blocky[i]-1);
		}
		if(blocky[i]==1)
		{
			mh=min(mh,blockx[i]-1);
		}
	}
	//cout<<mh<<' '<<ml<<endl;
	for(int i=1;i<=ml;i++)
	{
		yw[i]=h+1;
	}
	for(int i=1;i<=mh;i++)
	{
		xw[i]=w+1;
	}
	for(int i=1;i<=m;i++)
	{
		yw[blocky[i]]=min(yw[blocky[i]],blockx[i]);
		xw[blockx[i]]=min(xw[blockx[i]],blocky[i]);
	}
	int ans=0;
	for(int i=1;i<=mh;i++)ans+=xw[i]-1;
	for(int i=1;i<=ml;i++)
	{
		//cout<<yw[i]<<' ';
		ans+=yw[i]-1;
		ww[i].pos=i,ww[i].val=yw[i];
		add(i,1);
	}
	int now=1;
	sort(ww+1,ww+1+ml,cmp);
	//cout<<ans<<endl;
	for(int i=1;i<=mh;i++)
	{
		while(now<=ml&&ww[now].val+1==i)add(ww[now].pos,-1),now++;
		ans-=find(xw[i]-1);
	}
	cout<<ans;
	return 0;
}
/*
3 4 3
1 3
3 3
2 2
*/ 