#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>

using namespace std;

template <class T>
class bit {
    public:
    bit(int n);
    bit(T* array, int n);
    ~bit();
    void add(int x, T value);
    T get(int x) const; // [0, x]
    T get(int x, int y) const; // [x, y]
    int lower_bound(T value) const;
    int upper_bound(T value) const;
    int rlower_bound(T value) const;
    int rupper_bound(T value) const;
    
    private:
    int size;
    int high;
    T* data;
};

template <class T> bit<T>::bit(int n) : size(n + 1), high(1 << (31 - __builtin_clz(n))) {
    data = (T *)calloc(size, sizeof(T));
}

template <class T> bit<T>::bit(T* array, int n) : bit(n) {
    for (int i = 0; i < n; i++) data[i + 1] = array[i];
    for (int i = 1; i < n; i++) {
        if (i + (i & -i) < size) data[i + (i & -i)] += data[i];
    }
}

template <class T> bit<T>::~bit() {
    free(data);
}

template <class T> void bit<T>::add(int x, T value) {
    for (x++; x < size; x += x & -x) data[x] += value;
}

template <class T> T bit<T>::get(int x) const {
    T value = 0;
    for (x++; x > 0; x -= x & -x) value += data[x];
    return value;
}

template <class T> T bit<T>::get(int x, int y) const {
    return get(y) - get(x - 1);
}

template <class T> int bit<T>::lower_bound(T value) const {
    int x = 0;
    for (int i = high; i > 0; i >>= 1) {
        if (x + i < size && data[x + i] < value) value -= data[x += i];
    }
    return x;
}

template <class T> int bit<T>::upper_bound(T value) const {
    return lower_bound(value + 1);
}

template <class T> int bit<T>::rlower_bound(T value) const {
    int x = 0;
    for (int i = high; i > 0; i >>= 1) {
        if (x + i < size && data[x + i] <= value) value -= data[x += i];
    }
    return x - 1;
}

template <class T> int bit<T>::rupper_bound(T value) const {
    return rlower_bound(value - 1);
}

int x[200000];
int y[200000];
int xm[200001];
int ym[200001];

int main() {
    int h, w, m, i, j;
    long long ans = 0;
    vector<pair<int, int>> v;
    
    scanf("%d %d %d", &h, &w, &m);
    
    for (i = 0; i < m; i++) scanf("%d %d", &x[i], &y[i]);
    
    for (i = 1; i <= w; i++) xm[i] = h;
    for (i = 1; i <= h; i++) ym[i] = w;
    
    for (i = 0; i < m; i++) {
        xm[y[i]] = min(xm[y[i]], x[i] - 1);
        ym[x[i]] = min(ym[x[i]], y[i] - 1);
    }
    
    for (i = 2; i <= ym[1]; i++) v.push_back(make_pair(xm[i], i));
    
    sort(v.begin(), v.end());
    
    bit<long long> b(w + 2);
    
    for (i = 1, j = 0; i <= h; i++) {
        if (i <= xm[1]) {
            ans += ym[i];
            
            b.add(ym[i] + 1, 1);
        } else {
            b.add(0, 1);
        }
        
        while (j < v.size() && v[j].first <= i) {
            int x = v[j].first;
            int y = v[j].second;
            
            ans += b.get(y);
            
            j++;
        }
    }
    
    printf("%lld\n", ans);
    
    return 0;
}

# include <bits/stdc++.h>
#define rep(i,l,r)for(int i=(l);i<(r);i++)
# define rrep(i,r,l) for(int i=(r); i>=l; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
typedef long long lint;
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; }
#define INF ((1LL<<62)-(1LL<<31)) /*オーバーフローしない程度に大きい数*/
#define MOD 1000000007
lint gcd(lint a,lint b){
    if(!b)return a;
    return gcd(b,a%b);
}
 
lint lcm(lint a,lint b){
    return a*b/gcd(a,b);
}

template< typename T >
struct BinaryIndexedTree {
  vector< T > data;

  BinaryIndexedTree(int sz) {
    data.assign(++sz, 0);
  }

  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};

void solve() {
    int h,w,n;
    cin >> h >>w >> n;
    vector<int> a(w,h),b(h,w);
    
    rep(i,0,n){
        int x,y;
        cin >> x >> y;x--,y--;
        chmin(a[y],x);
        chmin(b[x],y);
    }
    lint ans=0;
    rep(y,0,b[0]) ans+=a[y];
    rep(x,0,a[0]) ans+=b[x];

    BinaryIndexedTree<int> t(w);
    rep(i,0,b[0]) t.add(i, 1);
    
    vector<vector<int>> ends(h+1);
    rep(y,0,b[0]) ends[a[y]].push_back(y);

    rep(x,0,a[0]){
        for(int y:ends[x]) t.add(y,-1);
        ans-=t.sum(b[x]-1);
    }
    cout << ans << endl;

}

signed main() {

    solve();

    return 0;
}