#include<bits/stdc++.h>
using namespace std;
using namespace std::chrono; 
const int mod=998244353;
const int mex=200005;
#define ll long long 
#define test int t;cin>>t;while(t--)
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fo(i,a,n) for(int i=a;i<n;i++)
#define rfo(i,a,b) for(int i=a;i>=b;i--)
#define bg begin()
#define en end()
#define fi first
#define se second
#define ub upper_bound
#define lb lower_bound
#define pb push_back
#define veci vector<int>
#define veclli vector<long long int> 
#define all(x) x.begin(),x.end()
#define sci(x) scanf("%d",&x);
#define scc(x) scanf("%c",&x);
#define scs(x) scanf("%s",x);
#define debug(arr,n) for(int i=0;i<n;i++) printf("%d ",arr[i]);
#define sz(x) x.size()
#define loop(x) for(auto it=x.begin();it!= x.end();it++)
#define int long long
int bite[mex];
void update(int x,int vl)
{
    while(x<mex)
    {
        bite[x]+=vl;
        x+=x&-x;
    }
}
int query(int x)
{
    int sum=0;
    while(x)
    {
        sum+=bite[x];
        x-=x&-x;
    }
    return sum;
}

signed main()
{
    int n,m,w;
    cin>>n>>m>>w;
    int x[n+2];
    int y[m+2];
    fo(i,0,n+2)
    x[i]=m+1;
    fo(i,0,m+2)
    y[i]=n+1;
    fo(i,0,w)
    {
        int x1,y1;
        cin>>x1>>y1;
        x[x1]=min(x[x1],y1);
        y[y1]=min(y[y1],x1);
    }
    int ans=0;
    fo(i,1,x[1])
    {
        ans=ans+y[i]-1;
    }
    fo(i,1,y[1])
    ans=ans+x[i]-1;
    //cout<<ans<<endl;
    int y1=x[1];
    vector<int> v[n+3];
    fo(i,1,y1)
    {
        v[y[i]].pb(i);
    }
    fo(i,1,n+1)
    {
        if(i<y[1])
        update(x[i],1);
        fo(j,0,sz(v[i+1]))
        ans=ans-(query(mex-1)-query(v[i+1][j]));
    }
    cout<<ans<<endl;




  
}
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <iostream>
#include <sstream>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <vector>

using namespace std;

typedef long long LL;

class BIT {
    std::vector<long long> bit;
    long long size;
public:
    BIT() { }
    BIT(long long sz) { init(sz); }
    void init(long long sz) {
        bit = std::vector<long long>((size = sz) + 1);
    }
    long long sum(long long i) {
        LL s = 0;
        while (i > 0) {
            s += bit[i];
            i -= i & -i;
        }
        return s;
    }
    void add(long long i, long long x) {
        while (i <= size) {
            bit[i] += x;
            i += i & -i;
        }
    }
};

LL solve(long long H, long long W, long long M, std::vector<long long> X, std::vector<long long> Y) {
    LL right = W;
    vector<LL> min_height(W, H);
    vector<vector<LL>> blocks(H);
    for (LL i = 0; i < M; ++i) {
        min_height[Y[i]] = min(min_height[Y[i]], X[i]);
        if (X[i] == 0) {
            right = min(right, Y[i]);
        }
        blocks[X[i]].emplace_back(Y[i]);
    }
	LL ans = 0;
    for (LL i = 0; i < right; ++i) {
        ans += min_height[i];
    }
    BIT bit(W);
    vector<bool> used(W);
    for (LL i = right; i < W; ++i) {
        bit.add(i + 1, 1);
        used[i] = true;
    }
    for (LL i = 1; i < min_height[0]; ++i) {
        sort(blocks[i].begin(), blocks[i].end());
        LL right = blocks[i].empty() ? W : blocks[i][0];
        ans += bit.sum(right);
        for (auto j : blocks[i]) {
            if (!used[j]) {
                used[j] = true;
                bit.add(j + 1, 1);
            }
        }
    }
    return ans;
}

int main() {
#if DEBUG
    freopen("in_2.txt", "r", stdin);
#endif

    long long H, W, M;
    cin >> H >> W >> M;
    std::vector<long long> X(M), Y(M);
    for (int i = 0 ; i < M ; i++) {
        cin >> X[i] >> Y[i];
        --X[i]; --Y[i];
    }
    cout << solve(H, W, M, std::move(X), std::move(Y)) << endl;
	return 0;
}
