#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
const int N = 2e5 + 10;

int h, w, m;

struct BIT{
    private:
        vector<LL> node;
        int n;
    public:
        BIT(int _n){
            n=_n;
            node.resize(n,0);
        }

        void add(int a,LL w){
            for(int i=a;i<n;i|=i+1){
                node[i]+=w;
            }
        }
        //sum[0,a)
        LL sum(int a){
            LL res=0;
            for(int i=a-1;i>=0;i=(i&(i+1))-1){
                res+=node[i];
            }
            return res;
        }
        //[a,b)
        LL sum(int a,int b){
            return sum(b)-sum(a);
        }
};

void solve(){
    int h,w;
    cin>>h>>w;
    int m;
    cin>>m;
    vector<int> x(m),y(m);
    
    for(int i=0;i<m;i++){
        cin>>x[i]>>y[i];
        x[i]--,y[i]--;
    }

    int lash=h,lasw=w;
    for(int i=0;i<m;i++){
        if(y[i]==0) lash=min(lash,x[i]);
        if(x[i]==0) lasw=min(lasw,y[i]);
    }

    LL ans=0;
    vector<int> rih(lash,w);
    for(int i=0;i<m;i++){
        if(x[i]<lash) rih[x[i]]=min(rih[x[i]],y[i]);
    }
    vector<int> riw(lasw,h);
    for(int i=0;i<m;i++){
        if(y[i]<lasw) riw[y[i]]=min(riw[y[i]],x[i]);
    }

    for(int i=0;i<lash;i++) ans+=rih[i];
    for(int i=0;i<lasw;i++) ans+=riw[i];

    vector<vector<int>> dels(w+1);
    for(int i=0;i<lash;i++){
        dels[rih[i]].push_back(i);
    }
    BIT bt(h);
    for(int i=0;i<lash;i++) bt.add(i,1);
    for(int i=0;i<lasw;i++){
        for(int d:dels[i]) bt.add(d,-1);
        ans-=bt.sum(riw[i]);
    }

    cout<<ans;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    solve();

    return 0;
}
#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define int long long int
#define endl "\n"
#define MOD 1000000007
#define mod 1000000007
#define M 1000000007
#define pb push_back
#define take(a,b,c) for(int b=0;b<c;b++) cin>>a[b]
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mx 1000005
#define fiint(a,b) memset(a,b,sizeof(a))
#define bitcount __builtin_popcount
#define fori(i,a,b) for(int i=a;i<b;i++)
#define ford(i,a,b) for(int i=a;i>=b;i--)
#define debug(x) cout<<x<<endl;
#define cases(t) int t; cin>>t; while(t--)
#define inf1 INT_MAX
#define all(a) a.begin(),a.end()
#define vec vector<int>
#define pii pair<int,int>
#define plii pair<int,int>
#define pint pair<int,int>
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define mp make_pair
 
#define sz(x) (int)x.size()
#define PI    3.14159265359

//const long long INF=1e18;

bool chmin(int& a, int b){ if(a > b){ a = b; return 1; } return 0; }

 
int factorial[10000001]={0};
 
int gcd(int a, int b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}


int powerFunction(int x,int y){
    int res = 1;
     int p = mod;
    x = x;
    while (y > 0){
        if (y & 1)
            res = (res*x)%p ;
        y = y>>1;
        x = (x*x)%p ;
    }
    return res;
}

void factorialFunction(int maxLimit){
    factorial[0]=1;
    for(int i=1 ; i <= maxLimit ; i++)
    factorial[i]=(factorial[i-1]*i)%MOD;
    return;
}
 
int nCr(int n, int r)
{
    if(r < 0 || r > n){
        return 0;
    }
    int temp = factorial[n];
    temp *= (powerFunction(factorial[r], MOD-2)%MOD);
    temp %= MOD;
    temp *= (powerFunction(factorial[n-r], MOD-2)%MOD);
    temp %= MOD;
    return temp;
}

vec tree(8 * 100005);

void update(int node , int st , int en , int idx , int v)
{
    if( st == en )
    {tree[node] = v; return;}
    
    int mid = (st + en)/2;
    
    if(idx <= mid)
        update(node*2, st, mid, idx, v);
    else update(node*2 + 1 , mid+1,en , idx, v);
    tree[node] = tree[2*node] + tree[2*node + 1];
}

int sum(int node , int st ,int en ,int l ,int r)
{
    if(en < l || r < st )
        return 0 ;
    if(l <= st && r >= en )
        return tree[node];
    int mid = (st + en)/2;
    return sum(node*2 , st , mid , l ,r) + sum(node*2 + 1, mid+1, en , l ,r);
}



signed main()
{
    int h,w,m ; cin>>h>>w>>m;
    vector<vec> row(h);
    vector<vec> col(w);
    vector<pii> obs;
    for(int i = 1 ; i <= m ;i++)
    {
        int x,y ; cin>>x>>y;
        x-- ; y--;
        obs.pb(mp(x,y));
    }
    sort(all(obs));
    for(int i = 0 ; i < m ;i++)
    {
        int x = obs[i].ff ;
        int y = obs[i].ss;
        row[x].pb(y); col[y].pb(x);
    }
    
    for(int i = 0 ; i < w ; i++)
    col[i].pb(h);
    
    for(int i = 0 ; i < h ; i++)
    row[i].pb(w);
    
    int ma_r ,  ma_c ;
    ma_r = col[0].front();
    ma_c = row[0].front();
    int ans = 0 ;
    for(int i = 0 ; i < ma_r;i++)
    {
        ans += row[i].front();
    }
    
    for(int i = 0 ; i < ma_c;i++)
    {
        int reach =  col[i][0];
       ans += max( (int)0 , reach - ma_r  );
      ans += sum(1, 0, h,0, min(reach ,ma_r )-1  );
      for(int x : col[i])
        update( 1 , 0 , h, x , 1);
    }
    cout << ans<<endl;
    
    
    
}
    


