#include<stdio.h> 
#include<algorithm>
#include<random>
#include<queue>
#include<map>
#include<time.h>
#include<string>
using namespace std;
using lld = long long int;
using pii = pair<int, int>;
using pll = pair<lld, lld>;
using pli = pair<lld, int>;
using pil = pair<int, lld>;
using lf = double;
int n, m;
int lv[200009];
int dv[200009];
int a[200009];
int b[200009];
int al, bl;
#define I 262144
lld ms[2 * I];
lld getms(int dep, int ql, int qr, int ll, int rr) {
    if (ql <= ll && rr <= qr)return ms[dep];
    if (qr < ll || rr < ql)return 0;
    return getms(dep * 2, ql, qr, ll, (ll + rr) / 2) + getms(dep * 2 + 1, ql, qr, (ll + rr) / 2 + 1, rr);
}
void updatems(int i, int k) {
    i += I;
    while (i > 0) {
        ms[i]+=k;
        i >>= 1;
    }
}
vector<int> rv[200009];
int main()
{
    int i, j, k, l;
    int t = 1, tv = 0;
    while (t--) {
        scanf("%d %d", &n, &m);
        for (i = 0; i < n; i++) {
            lv[i] = m;
        }
        for (i = 0; i < m; i++) {
            dv[i] = n;
        }
        int p;
        scanf("%d", &p);
        while (p--) {
            scanf("%d %d", &i, &j);
            i--; j--;
            lv[i] = min(lv[i], j);
            dv[j] = min(dv[j], i);
        }
        lld res = 0;
        al = dv[0];
        for (i = 0; i < al; i++) {
            a[i] = lv[i];
            res += a[i];
            updatems(i, 1);
            rv[a[i]].push_back(i);
        }
        bl = lv[0];
        for (i = 0; i < bl; i++) {
            b[i] = dv[i];
            res += b[i];
            res -= getms(1, 0, b[i] - 1, 0, I - 1);
            for (auto it : rv[i]) {
                updatems(it, -1);
            }
        }
        printf("%lld\n", res);


    }
}
// Created by ash_98

#include<bits/stdc++.h>
using namespace std;

#define Gene template< class
#define Rics printer& operator,
Gene c> struct rge{c b, e;};
Gene c> rge<c> range(c i, c j){ return {i, j};}
struct printer{
    ~printer(){cerr<<endl;}
    Gene c >Rics(c x){ cerr<<boolalpha<<x; return *this;}
    Rics(string x){cerr<<x;return *this;}
    Gene c, class d >Rics(pair<c, d> x){ return *this,"(",x.first,", ",x.second,")";}
    Gene ... d, Gene ...> class c >Rics(c<d...> x){ return *this, range(begin(x), end(x));}
    Gene c >Rics(rge<c> x){
        *this,"["; for(auto it = x.b; it != x.e; ++it)
            *this,(it==x.b?"":", "),*it; return *this,"]";}
};
#define debug() cerr<<"LINE "<<__LINE__<<" >> ", printer()
#define dbg(x) "[",#x,": ",(x),"] "
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int my_rand(int l, int r) {
    return uniform_int_distribution<int>(l, r) (rng);
}

#define mx 200005
#define ll long long
#define mod 1000000007


char ch[mx];
int n,m,ii,k;
int row[mx],col[mx];

namespace Segment_Tree
{
	const int N=200005;
	vector<int>Tree[N*4];
	int Lazy[mx*4];
	int ar[N];

	void Relax(int node,int be,int en)
	{
		if(!Lazy[node])return;

	//	Tree[node]+=Lazy[node];
		if(be!=en)
		{
			 Lazy[node*2]+=Lazy[node];
		
			Lazy[node*2+1]+=Lazy[node];

		}
		Lazy[node]=0;
	}

	void init(int node,int be,int en)
	{
		//Lazy[node]=0;
        if(be==en)
        {
        	Tree[node].push_back(ar[be]);
        	return;
        }
        int mid=(be+en)/2;
        init(node*2,be,mid);
        init(node*2+1,mid+1,en);
        merge(Tree[node*2].begin(),Tree[node*2].end(),Tree[node*2+1].begin(),Tree[node*2+1].end(),back_inserter(Tree[node]));

	}

	int query(int node,int be,int en,int i,int j,int val)
	{
		//Relax(node,be,en);
		if(be>j || en<i)return 0;
		if(be>=i && en<=j)
		{
			
            
            int st=0,fi=Tree[node].size()-1;
            int sz=Tree[node].size();
            int re=sz;
           
            while(st<=fi)
            {
            	int mid=(st+fi)/2;
            	if(Tree[node][mid]>=val)
            	{
            		re=mid;
            		fi=mid-1;
            	}
            	else st=mid+1;
            }

            
            return sz-re;
		}

		int mid=(be+en)/2;

		return (query(node*2,be,mid,i,j,val)+query(node*2+1,mid+1,en,i,j,val));
	}

	void dbg_test(int node,int be,int en)
	{
		if(be==en)return;
		int mid=(be+en)/2;
		dbg_test(node*2,be,mid);
		dbg_test(node*2+1,mid+1,en);
	}
}

using namespace Segment_Tree;

void solve()
{
	scanf("%d%d%d",&n,&m,&k);

	for(int i=1;i<=n;i++)row[i]=m;
	for(int i=1;i<=m;i++)col[i]=n;

	for(int i=1;i<=k;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		col[y]=min(col[y],x-1);
		row[x]=min(row[x],y-1);
	}

	ll re=0;
	int limi=row[1];
	re+=limi-1;
	for(int i=2;i<=limi;i++)
	{
		int jabe=col[i];
		re+=jabe-1;
		ar[i]=jabe;
		//cout<<i<<" "<<jabe<<endl;
	}
	
	init(1,1,m);

	limi=col[1];
	re+=limi;

	//cout<<re<<endl;
	
	for(int i=2;i<=limi;i++)
	{
		int r=row[i];
		int jabe=query(1,1,m,2,r,i);
        //cout<<i<<" "<<r-1<<" "<<jabe<<endl;
		re-=jabe;
		re+=r-1;

	}
	printf("%lld\n",re);
}

int main()
{
	int t=1;
	//scanf("%d",&t);
	while(t--)solve();
	return 0;
}