// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<random>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
typedef vector<vt>vvt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
ll extgcd(ll a, ll b, ll &x, ll &y) {
	ll g = a;
	x = 1;
	y = 0;
	if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
	return g;
}
ll crt(ll div1,ll mod1,ll div2,ll mod2){
	ll x,y;
	ll d=extgcd(div1,div2,x,y);
	if(d-1)assert(0);
	ll ndiv=div1*div2;
//	ll nmod=(x*(mod2-mod1)*div1+mod1)%ndiv;
	ll nmod=(mod1*div2%ndiv*(ndiv+y)%ndiv+mod2*div1%ndiv*(ndiv+x)%ndiv)%ndiv;
	return nmod;
}



typedef int SegT;
const SegT defvalue=0;
class SegTree{
	private:
		vector<SegT>val;
		int n;
		SegT combine(SegT a,SegT b){return a+b;}
	public:
		SegTree(int size){
			n=1;
			while(n<size)n<<=1;
			val=vector<SegT>(2*n,defvalue);
		}
		SegTree(const vector<SegT> &in){
			n=1;
			while(n<in.size())n<<=1;
			val=vector<SegT>(2*n,defvalue);
			for(int i=n-1+in.size()-1;i>=0;i--){
				if(n-1<=i)val[i]=in[i-(n-1)];
				else val[i]=combine(val[i*2+1],val[i*2+2]);
			}
		}
		void update(int i,SegT a){
			i+=n-1;
			val[i]=a;
			while(i>0){
				i=(i-1)/2;
				val[i]=combine(val[i*2+1],val[i*2+2]);
			}
		}
		SegT query(int a,int b,int k=0,int l=0,int r=-1){//[a,b)
			if(r==-1)r=n;
			if(r<=a||b<=l)return defvalue;
			if(a<=l&&r<=b)return val[k];
			else return combine(query(a,b,k*2+1,l,(l+r)/2),query(a,b,k*2+2,(l+r)/2,r));
		}
		void tmp(){
			rep(i,val.size())cout<<" "<<val[i];cout<<endl;
		}
};
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

	int n,m,x;
	cin>>n>>m>>x;
	vvi in(x,vi(2));
	rep(i,x)rep(j,2)cin>>in[i][j],in[i][j]--;
	vi h(n,m),w(m,n);
	rep(i,x){
		cmin(h[in[i][0]],in[i][1]);
		cmin(w[in[i][1]],in[i][0]);
	}
//	show1d(h);
//	show1d(w);
	int out=0;
	rep(i,w[0])out+=h[i];

	vp t;

	rep(i,w[0])t.pb({h[i],i});
	if(w[0]-n){
		t.pb({0,w[0]});
		loop(i,w[0]+1,n)t.pb({0,i});
	}
	sort(all(t));
	SegTree st(n);
	int it=0;
	rep(i,h[0]){
		//cout<<w[i]<<" "<<st.query(0,w[i])<<endl;
		out+=st.query(0,w[i]);
		while(it!=t.size()&&t[it].first==i){
//			cout<<t[it].first<<" "<<t[it].second<<endl;
			st.update(t[it].second,1);
			it++;
		}
	}
	cout<<out<<endl;
}
/*
 ....
 .#..
 #...
 ...#
 .#..

*/

/*
	int q;
	cin>>q;
	while(q--){
		int n,a,b;
		cin>>n>>a>>b;//b*x mod n == n-a
		int g=gcd(n,b);
		if(a%g){cout<<-1<<endl;continue;}
		a/=g;b/=g;n/=g;
//		cout<<n<<" "<<a<<" "<<b<<endl;
		cout<<crt(n,n-a,b,0)/b<<endl;

	}
}
// b*x mod n == n-a
// 3x mod 10 == 6
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 400005;

vector<int> BIT(N, 0);
vector<bool> seen(N, false);

void update(int x, int delta) {
	for (; x <= N; x += x & -x)
		BIT[x] += delta;
}
int query(int x) {
	int sum = 0;
	for (; x > 0; x -= x & -x)
		sum += BIT[x];
	return sum;
}
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int h, w, m;
	cin >> h >> w >> m;
	vector<int> row(h + 1, w + 1), col(w + 1, h + 1);
	vector<vector<int>> pos(N);

	for (int i = 1; i <= m; ++i) {
		int x, y;
		cin >> x >> y;
		pos[y].push_back(x);
		row[x] = min(row[x], y);
		col[y] = min(col[y], x);
	}
	ll res = 0;
	for (int i = 1; i < col[1]; ++i) res += row[i] - 1;
	for (int i = col[1] + 1; i <= h; ++i) {
		update(i, 1);
		seen[i] = 1;
	}
	for (int i = 1; i < row[1]; ++i) {
		res += query(col[i] - 1);
		for (int &v : pos[i]) {
			if (!seen[v]) update(v, 1);
			seen[v] = 1;
		}
	}
	cout << res << endl;
}