#include <bits/stdc++.h>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
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;}
static const ll INF=1e18;
static const ll MAX=101010;
//static const ll MOD=1e9+7;
static const ll MOD=998244353;
//for(i=0;i<N;i++) cin>>a[i];

class sumSegTree {
public:
  ll n, height;
  vector<ll> data;
  
  sumSegTree(ll _n) {
    n=1;
    height=1;
    while(n<_n) {
      n*=2;
      height++;
    }
    data=vector<ll>(2*n-1);
  }
  
  void add(ll i, ll x) {
    i+=n-1;
    data[i]+=x;
    while(i>0) {
      i=(i-1)/2;
      data[i]+=x;
    }
  }
  
  //[a, b):要求区間，[l, r):対象区間
  ll _sum(ll a, ll b, ll k, ll l, ll r) {
    if(r<=a || b<=l) return 0;
    if(a<=l && r<=b) return data[k];
    else {
      ll s=_sum(a, b, 2*k+1, l, (l+r)/2);
      ll t=_sum(a, b, 2*k+2, (l+r)/2, r);
      return s+t;
    }
  }
  
  ll sum(ll a, ll b) {
    return _sum(a, b, 0, 0, n);
  }
  
};

int main(void) {
  ll i, j, k;
  
  ll H,W,M;
  cin>>H>>W>>M;
  vector<vector<ll>> yoko(H,vector<ll>{W}),tate(W,vector<ll>({H}));
  for(i=0;i<M;i++){
    ll x,y;
    cin>>x>>y;x--;y--;
    yoko[x].push_back(y);
    tate[y].push_back(x);
  }
  for(i=0;i<H;i++) sort(yoko[i].begin(), yoko[i].end());
  for(j=0;j<W;j++) sort(tate[j].begin(), tate[j].end());
  
  ll ans=0;
  ll f=0;
  for(j=0;j<yoko[0][0];j++) ans+=tate[j][0];
  
  sumSegTree sst(W+1);
  for(j=yoko[0][0];j<W;j++) sst.add(j,1);
  for(i=0;i<tate[0][0];i++){
    ans+=sst.sum(0, yoko[i][0]);
    
    for(auto u:yoko[i]){
      if(sst.sum(u, u+1)==0)
        sst.add(u, 1);
    }
    
  }
  pt(ans);
  
}




#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <utility>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <functional>
#include <iterator>
#include <random>
#include <fstream>
#include <chrono>
#include <cctype>
using namespace std;
#define forn(i, n) for (int i = 0; i < n; ++i)
#define rforn(i, n) for (int i = n; i >= 0; --i)
#define int long long
const int N = 201337;

int ts=N * 4;
vector<vector<int>>d(ts);
vector<int> a;
void build(int v, int l, int r) {
    if (l == r - 1) {
        d[v].push_back(a[l]);
        return;
    }
    int m = (l+r)/2;
    build(2*v+1,l,m);
    build(2*v+2,m,r);
    merge(d[2*v+1].begin(),d[2*v+1].end(),d[2*v+2].begin(),d[2*v+2].end(),back_inserter(d[v]));
}
int get_res(int v,int l,int r, int L, int R, int k){
    if (r <= L || R <= l) {
        return 0;
    }
    if (L <= l && r <= R) {
        return d[v].end() - upper_bound(d[v].begin(),d[v].end(),k);
    }
    int m = (l+r)/2;
    int left = get_res(2*v+1,l,m,L,R,k);
    int right = get_res(2*v+2,m,r,L,R,k);
    return left+right;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int h, w, m;
    cin >> h >> w >> m;
    // храним для row минимальный
    // храним для column min
    vector<int>row(h + 3, w + 1); // сколько для строки я могу пройти вниз
    vector<int>col(w + 3, h + 1); // сколько для столбца я могу пройти вправо
    forn(i, m){
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        row[x] = min(row[x], y + 1);
        col[y] = min(col[y], x + 1);
    }
    a.assign(w, 0);
    int ans = 0;
    forn(i, row[0] - 1){ //
        //cout << "at col = " << i << "limit = " << max(0ll,col[i] - 1) << "\n";
        a[i] = max(0ll,col[i] - 1);
        ans += max(0ll,col[i] - 1);
    }
    //cout << ans << "\n";
//    forn(i, w){
//        if(col[i] == w)
//            col[i]++;
//    }
    build(0,0,w);
    forn(i, a[0]){
        int R = row[i] - 1;
        //cout << "at row = " << i + 1 << " we can take up to" << R  << "\n";
        //R--;
        int q = get_res(0,0,w,0,R,i);
        //cout << "q = " << q << "\n";
        ans += R - q;
    }
    cout << ans << "\n";
    return 0;
}
