#include<bits/stdc++.h>
#define ll long long
#define re register
#define INF 2147483647
using namespace std;

inline int read()
{
	int f=1,x=0;char s=getchar();
	while(s<'0'||s>'9')
	{
		if(s=='-') f=-1;
		s=getchar();
	}
	while(s>='0'&&s<='9')
	{
		x=x*10+s-48;
		s=getchar();
	}
	return f*x;
}

struct node
{
	int op;
	int x,y;
};

bool cmp(node a,node b)
{
	if(a.x!=b.x) return a.x<b.x;
	else return a.op<b.op;
} 

const int N=2e5+5;
vector<node> v;
vector<int> v1[N],v2[N];
const int mxv=2e5+5;
int t[mxv+5];

inline int lowbit(int x)
{
	return x&(-x);
}

inline void updata(int x,int v)
{
	for(;x<=mxv;x+=lowbit(x))
		t[x]+=v;
}

inline int ask(int x)
{
	int ans=0;
	for(;x;x-=lowbit(x))
		ans+=t[x];
	return ans;
}

int main()
{
	int n=read(),m=read();
	int k=read();
	for(int i=1;i<=k;i++)
	{
		int x=read(),y=read();
		v1[x].push_back(y-1);
		v2[y].push_back(x-1);
	}
	for(int i=1;i<=n;i++) v1[i].push_back(m);
	for(int i=1;i<=m;i++) v2[i].push_back(n);
	for(int i=1;i<=n;i++) sort(v1[i].begin(),v1[i].end());
	for(int i=1;i<=m;i++) sort(v2[i].begin(),v2[i].end());
	ll ans=v1[1][0]+v2[1][0]-1;
	//cout<<ans<<endl; 
	for(int i=2;i<=n;i++) 
	{
		if(i>v2[1][0]) break;
		//cout<<v1[i][0]<<endl;
		ans+=v1[i][0]-1;
		//cout<<ans<<endl;
	}		
//	cout<<ans<<endl;
	for(int i=2;i<=n;i++) v.push_back((node){1,i,v1[i][0]});
	for(int i=2;i<=m;i++) v.push_back((node){2,v2[i][0],i});
	sort(v.begin(),v.end(),cmp);
	//for(int i=0;i<v.size();i++) printf("%d %d %d\n",v[i].op,v[i].x,v[i].y);
	for(int i=0;i<v.size();i++)
	{//printf("%d %d %d\n",v[i].op,v[i].x,v[i].y);
		if(v[i].op==1) 
		{
			if(v[i].x>v2[1][0]) continue;
			//cout<<v[i].y+1<<endl;
			updata(v[i].y+1,1);
		}
		else 
		{
			//if(v[i].x==0) continue;
			if(v[i].y>v1[1][0]) continue; 
			//cout<<ask(v[i].y)-ask(mxv)<<endl;
			ans+=v[i].x-1+ask(v[i].y)-ask(mxv);
		}
		//cout<<ans<<endl;
	}
	printf("%lld\n",ans);
	return 0;
}
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
using pii = pair<int, int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template<typename T>
struct SegmentTree{
  using OP = function<T(T,T)>;

  int n, defn;
  vector<T> node;
  T t;
  OP op;

  SegmentTree(int n_, T t, OP op) : t(t),op(op){
    n = 1;
    defn = n_;
    while(n < n_) n<<=1;
    node.assign(2*n,t);
  }

  void init(int n_){
    n = 1;
    defn = n_;
    while(n < n_) n<<=1;
    node.assign(2*n,t);
  }

  void set(int k,T x){
    assert(0 <= k && k < n);
    node[k+n] = x;
  }

  void build(){
    for(int k = n - 1; k > 0; k--){
      node[k] = op(node[2*k],node[2*k+1]);
    }
  }

  void change(int k, T x){
    assert(0 <= k && k < n);
    k += n;
    node[k] = x;
    while(k >>= 1){
      node[k] = op(node[2*k],node[2*k+1]);
    }
  }

  void change(int l, int r, T x){
    for(int k = l; k < r; k++) change(k,x);
  }

  T at(int k){
    assert(0 <= k && k < n);
    return node[k+n];
  }

  void add(int k, T a){
    assert(0 <= k && k < n);
    T x = at(k)+a;
    change(k,x);
  }

  T query(int a, int b){
    assert(0 <= a && b <= n);
    if(a==0 && b==defn) return all_query();
    T L = t, R = t;
    for(a += n, b += n; a < b; a >>= 1, b >>= 1) {
      if(a & 1) L = op(L, node[a++]);
      if(b & 1) R = op(node[--b], R);
    }
    return op(L, R);
  }

  T all_query() { return node[1]; }

  template<typename C>
  int max_right(int l, C &check){
    if(l == defn) return defn;
    l += n;
    T tm = t;
    do{
      while(l%2 == 0) l >>= 1;
      if(!check(op(tm, node[l]))){
        while(l < n){
          l *= 2;
          if(check(op(tm, node[l]))){
            tm = op(tm, node[l]);
            l++;
          }
        }
        return l - n;
      }
      tm = op(tm, node[l]);
      l++;
    }while((l&-l) != l);
    return defn;
  }

  template<typename C>
  int max_left(int r, C &check){
    if(r == 0) return 0;
    r += n;
    T tm = t;
    do{
      r--;
      while(r>1 && (r%2)) r >>= 1;
      if(!check(op(node[r], tm))){
        while(r < n){
          r = 2*r + 1;
          if(check(op(node[r], tm))){
            tm = op(node[r], tm);
            r--;
          }
        }
        return r + 1 - n;
      }
      tm = op(node[r], tm);
    }while((r&-r) != r);
    return 0;
  }
};



int main(){
  int H, W, M; cin >> H >> W >> M;
  vector<int> height(W, H), width(H, W);
  vector<vector<int>> ps(H);

  rep(i, M){
    int x, y; cin >> x >> y; x--; y--;
    chmin(height[y], x); chmin(width[x], y);
    ps[x].emplace_back(y);
  }

  ll ans = 0;

  SegmentTree<int> seg(
    W,
    0,
    [](int a, int b) { return a+b; }
  );
  
  rep(i, W){
    if(i < width[0]) ans += height[i];
    else seg.set(i, 1);
  }
  seg.build();

  rep(i, height[0]){
    for(auto&&y : ps[i]){
      seg.change(y, 1);
    }
    ans += seg.query(0, width[i]);
  }

  cout << ans << endl;
}