#include<bits/stdc++.h>

using namespace std;

typedef long long LL;

struct BIT{
    vector<LL> node;
    int size;

    BIT(int n){
        size=n;
        node.resize(size,0);
    }

    void add(int a,int x){
        for(int i=a;i<size;i|=i+1) node[i]+=x;
    }

    LL sum(int a){
        LL res=0;
        for(int i=a-1;i>=0;i=(i&(i+1))-1){
            res+=node[i];
        }
        return res;
    }
};

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

    int h,w,m;
    cin>>h>>w>>m;

    vector<int> x(m),y(m);
    for(int i=0;i<m;i++){
        cin>>x[i]>>y[i];
        x[i]--,y[i]--;
    }

    int clsh=h,clsw=w;
    for(int i=0;i<m;i++){
        if(x[i]==0) clsw=min(clsw,y[i]);
        if(y[i]==0) clsh=min(clsh,x[i]);
    }

    vector<int> rih(clsh,w);
    for(int i=0;i<m;i++){
        if(x[i]<clsh) rih[x[i]]=min(rih[x[i]],y[i]);
    }
    vector<int> riw(clsw,h);
    for(int i=0;i<m;i++){
        if(y[i]<clsw) riw[y[i]]=min(riw[y[i]],x[i]);
    }

    LL res=0;
    for(int i=0;i<clsh;i++) res+=rih[i];
    for(int i=0;i<clsw;i++) res+=riw[i];

    vector<vector<int>> dels(w+1);
    for(int i=0;i<clsh;i++) dels[rih[i]].push_back(i);

    BIT bt(h);
    for(int i=0;i<clsh;i++) bt.add(i,1);
    for(int i=0;i<clsw;i++){
        for(int d:dels[i]) bt.add(d,-1);
        res-=bt.sum(riw[i]);
    }

    cout<<res;

    return 0;
}
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")

#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define i_os ios::sync_with_stdio(0);  cin.tie(0);  cout.tie(0);
#define INF (ll)1e18 + 100
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
// SOME BITMASK KNOWLEDGE
// 1)x & (x - 1):sets the last one bit of x to zero
// power of two exactly when x & (x − 1) = 0.
// 2)x & -x:sets all the one bits to zero, except last one bit
// 3)x | (x - 1):inverts all the bits after the last one bit
#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define o_setll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set1;
typedef tree<string,null_type,less<string>,rb_tree_tag,tree_order_statistics_node_update> indexed_set2;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);

ll power(ll a,ll n,ll c){
    if(n == 0) return 1 % c;
    ll s = power(a,n/2,c);
    s = (s * s) % c;
    if(n % 2) s = (s * a) % c;
    return s;
}

int main()
{
	i_os;
	// freopen("output.txt","w",stdout);
	ll h,w,m;
	cin>>h>>w>>m;
	vector<set<ll>> edges1,edges2;
	edges1.resize(h,set<ll>());
	edges2.resize(w,set<ll>());
	// set<ll> edges1[h],edges2[w];
	REP(i,0,m){
		ll x,y;
		cin>>x>>y;
		edges1[x-1].insert(y-1);
		edges2[y-1].insert(x-1);
	}
	vector<ll> col(w),row(h);
	bool f = 0;
	REP(i,0,w){
		if(edges2[i].size()){
			if(f){
				col[i] = -1;
			}
			else {
				col[i] = *edges2[i].begin() - 1;
				if(col[i] == -1) f = 1;
			}
		}
		else {
			if(f) col[i] = -1;
			else col[i] = h-1;
		}
	}
	f = 0;
	REP(i,0,h){
		if(edges1[i].size()){
			if(f){
				row[i] = -1;
			}
			else {
				row[i] = *edges1[i].begin() - 1;
				if(row[i] == -1) f = 1;
			}
		}
		else {
			if(f) row[i] = -1;
			else row[i] = w-1;
		}
	}
	ll ans = 0;
	REP(i,0,w){
		ans += col[i] + 1;
	}
	vector<pair<ll,ll>> v;
	REP(i,0,h){
		if(row[i] >= 0){
			v.push_back({row[i],i});
		}
	}
	sort(v.begin(),v.end());
	indexed_set s;
	ll curr = -1,v1 = 1;
	for(auto it:v){
		while(curr < it.first){
			curr++;
			s.insert({col[curr],v1});
			v1++;
		}
		ans += s.order_of_key({it.second,0});
	}
	cout<<ans<<endl;
    return 0;
}
