#include <bits/stdc++.h>
#define ll long long
#define V vector<long long>
#define VV vector<vector<long long>>
#define VVV vector<vector<vector<long long>>>
#define P pair<ll,ll>
#define rep(i,n) for(ll (i)=0;(i)<(n);++(i))
using namespace std;

template<typename T>
struct segment_tree{
    function<T(T,T)> f = [](T a, T b){return a+b;};
    T inf=0;
    vector<T> value;
    int N;
    segment_tree(int n){
        N=1;
        while(N<n)N*=2;
        value.assign(2*N-1,inf);
    }
    segment_tree(int n, function<T(T,T)> func, T t1){
        N=1;
        while(N<n)N*=2;
        value.assign(2*N-1,t1);
        f=func;
        inf=t1;
    }
    void update(int i,T x){
        i+=N-1;
        value[i]=x;
        while(i>0){
            i=(i-1)/2;
            value[i]=f(value[i*2+1],value[i*2+2]);
        }
    }
    T query(T a,T b){
        return query(a,b,0,0,N);
    }
    T query(T a,T b, int k, int l, int r){
        if(r<=a || b<=l)return inf;
        if(a<=l && r<=b){
            return value[k];
        }else{
            ll c1=query(a,b,2*k+1,l,(l+r)/2);
            ll c2=query(a,b,2*k+2,(l+r)/2,r);
            return f(c1,c2);
        }
    }
    void print(){
        for(int i=0;i<ceil(log2(N))+1;i++){
            for(int j=0;j<(1<<i);j++){
                cout<<value[j+(1<<i)-1]<<((j==(1<<i)-1)?';':',');
            }
            cout<<endl;
        }
    }
};

int main() {
    ll h,w,m;
    cin>>h>>w>>m;
    V tatem(w,h);
    V yokom(h,w);
    VV mm(h,V());
    rep(i,m){
        ll x,y;
        cin>>y>>x;
        x--;y--;
        tatem[x]=min(tatem[x],y);
        yokom[y]=min(yokom[y],x);
        mm[y].push_back(x);
    }
    ll ans=0;
    rep(i,yokom[0]){
        ans+=tatem[i];
    }
    segment_tree<ll> sg(w);
    rep(i,tatem[0]){
        if(i==0){
            rep(j,w){
                if(j<yokom[0]){
                    sg.update(j,0);
                }else{
                    sg.update(j,1);
                }
            }
        }else{
            ans+=sg.query(0,yokom[i]);
            for(ll x:mm[i]){
                sg.update(x,1);
            }
        }
    }
    cout<<ans<<endl;
}

#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
const int MAX = 200000;

template<class T> class segtree{
	public:
	T *tree;
	T u;
	int height,treeSize,dataSize;
	segtree(long long int length,T unit){
		long long int pre = 1;
		height=1;
		u=unit;
		while(pre<length){
			pre*=2;
			height++;
		}
		
		treeSize = pre*2-1;
		dataSize = pre;
		tree = new T[treeSize];
		
		for(int i=0;i<dataSize;i++)set(i,unit);
		construct();

	}
	void replace(long long int index, T value){
		tree[treeSize-dataSize+index]=value;
		index=treeSize-dataSize+index+1;
		while(index>0){
			index/=2;
			tree[index-1]=f(tree[index*2-1],tree[index*2]);
		}
	}
	T result(long long int l,long long int r){return result(l,r,0,1<<(height-1),0);}
	T result(long long int l,long long int r,int s,int len,long long int ind){
		if(l==r)return get(l);
		else if(l==s && r==s+len-1)return tree[ind];
		len/=2;
		
		T res=u;
		long long int L=s,R=s+len-1;
		if(!(r<L || R<l))res=f(result(max(L,l),min(R,r),L,len,ind*2+1),res);
		L+=len;R+=len;
		if(!(r<L || R<l))res=f(result(max(L,l),min(R,r),L,len,ind*2+2),res);
		return res;
	}
	
	void construct(){for(int i=treeSize-2;i>0;i-=2)tree[i/2]=f(tree[i],tree[i+1]);}
	void set(long long int index, T value){tree[treeSize-dataSize+index]=value;}
	T get(long long int index){return tree[treeSize-dataSize+index];}
	
	T f(T a,T b){
		return a+b;
	}
};

int main(){
	bool flag=true;
	long long int H,W,M,X,Y,ans=0;
	vector<long long int> row[MAX];
	cin>>H>>W>>M;
	
	segtree<long long int> seg(W,0);
	
	for(int i=0;i<W;i++)seg.set(i,0);
	seg.construct();
	
	for(int i=0;i<M;i++){
		cin>>X>>Y;X--;Y--;
		row[X].push_back(Y);
	}
	for(int i=0;i<H;i++){
		row[i].push_back(W);
		sort(row[i].begin(),row[i].end());
		
		if(row[i][0]==0)flag=false;
		ans+=row[i][0];
		if(!flag)ans-=seg.result(0,row[i][0]-1);
		if(i==0){
			for(int j=row[i][0];j<W;j++)seg.set(j,1);
			seg.construct();
		}else{
			for(int j=1;j<row[i].size();j++){
				if(row[i][j-1]+1==row[i][j])continue;
				ans+=(row[i][j]-1)-(row[i][j-1]+1)+1-seg.result(row[i][j-1]+1,row[i][j]-1);
			}
			for(int j=0;j<row[i].size()-1;j++)seg.replace(row[i][j],1);
		}
	}
	cout<<ans;
	return 0;
}