
// Problem: F - Rook on Grid
// Contest: AtCoder - Panasonic Programming Contest (AtCoder Beginner Contest 186)
// URL: https://atcoder.jp/contests/abc186/tasks/abc186_f
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define pb push_back
#define int long long
#define F(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end()

using ld = long double;
using vi = vector <int>;
using mi = map <int, int>;
using pii = pair <int, int>;

const int N = 200005;
const int MOD = 1e9 + 7;

#define show(arr) { for (auto x: arr) cout << x << " "; cout << '\n'; }
#define show_(arr, n) F(i, n) show(arr[i])
/*
~Segment tree~
use v=1, tl=0, tr=n-1
*/
int t[4*N];
int operation(int a,int b) {return a+b;}

void build(vi &a, int v, int tl, int tr) {
    if (tl == tr) {
        t[v] = a[tl];
    } else {
        int tm = (tl + tr) / 2;
        build(a, v*2, tl, tm);
        build(a, v*2+1, tm+1, tr);
        t[v] = operation(t[v*2],t[v*2+1]);
    }
}
int sum(int v, int tl, int tr, int l, int r) {
    if (l > r) 
        return 0;
    if (l == tl && r == tr) {
        return t[v];
    }
    int tm = (tl + tr) / 2;
    return operation(sum(v*2, tl, tm, l, min(r, tm))
           ,sum(v*2+1, tm+1, tr, max(l, tm+1), r));
}
void update(int v, int tl, int tr, int pos, int new_val) {
    if (tl == tr) {
        t[v] = new_val;
    } else {
        int tm = (tl + tr) / 2;
        if (pos <= tm)
            update(v*2, tl, tm, pos, new_val);
        else
            update(v*2+1, tm+1, tr, pos, new_val);
        t[v] = operation(t[v*2],t[v*2+1]);
    }
}
vi rr[N], cc[N];
int r[N], c[N];
void solve() {
	int rows,colmn,k, ans = 0; cin>>rows>>colmn>>k;
	vi a(rows,0);
	F(i,N){
		r[i] = colmn;
		c[i] = rows;
	}
   	F(i, k){
   		int x,y; cin >> x >> y; x--; y--;
   		r[x] = min(r[x],y);
   		c[y] = min(c[y],x);
   		rr[x].pb(y);
   		cc[y].pb(x);
   	}
   	bool ok=1;
	F(i,rows){
		if(r[i]==0) ok=0;
		if(ok) 
			ans += r[i];
		else 
			a[i]=1;
	}
	build(a, 1, 0, rows-1);
	F(i,colmn){
		int bound = c[i];
		if(bound == 0) break;
		ans += sum(1, 0, rows-1,0,bound-1);
		for(int x: cc[i]) update(1, 0, rows-1,x,1);
	}   	
   	cout << ans << '\n';
}
int32_t main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);

   int32_t t=1;
   // cin >> t;
   while (t--) solve();

   return 0;
}
#include<bits/stdc++.h>
using namespace std;
#define ll long long
void update(int bit[],int n,int x, int val)
{
      for(; x <= n; x += x&-x)
        bit[x] += val;
}
int sum1(int bit[],int n)
{
     int sum = 0; int x=n;
     for(; x > 0; x -= x&-x)
        sum += bit[x];
     return sum;
}
int main()
{
    int h,w,m; cin>>h>>w>>m;
    map<int,int>mp,mp1;
    map<pair<int,int>,int>mp3;
    map<int,vector<int>>v;
    for(int i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        if(mp[x]==0) mp[x]=y;
        else
        mp[x]=min(mp[x],y);
        if(mp1[y]==0) mp1[y]=x;
        else
        mp1[y]=min(mp1[y],x);
        mp3[{x,y}]=1;
        v[y].push_back(x);
    }
    ll cnt=0;
    for(int i=1;i<=w;i++)
    {
        if(mp3[{1,i}]==0){

            if(mp1[i]==0) cnt+=h;
            else cnt+=mp1[i]-1;
            //cout<<cnt<<endl;
        }
        else break;
    }
    //cout<<cnt<<endl;
    int bit[h+1]={0}; bool has[h+1]={0}; bool flag=0;
    if(mp1[1]!=0)
    for(int i=mp1[1];i<=h;i++) update(bit,h,i,1),has[i]=1;
    for(int i=2;i<=w;i++)
    {
                for(auto it: v[i])
                {
                    if(has[it]==0){
                        update(bit,h,it,1);
                        has[it]=1;
                    }
                }
                if(flag==0){
                    if(mp1[i]!=0)
                    cnt+=h-(sum1(bit,h)-sum1(bit,mp1[i]-1))-(mp1[i]-1);
                }
                else
                    cnt+=h-sum1(bit,h);
                if(mp3[{1,i}]>=1) flag=1;


    }
    cout<<cnt<<endl;
}
