#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename T>bool chmin(T& x,const T&y) {if(x>y){x=y;return true;} else return false;}
template<typename T>bool chmax(T& x,const T&y) {if(x<y){x=y;return true;} else return false;}

template<typename T>
struct BIT {
    int n;
    vector<T> d;
    BIT(int n=0):n(n), d(n+1) {}
    void add(int i, T x=1) {
        for (i++; i <= n; i += i&-i) {
            //i&-iで最下位bitを足している
            d[i] += x;
        }
    }
    T sum(int i) {
        T x = 0;
        for (i++; i; i -= i&-i) {
            x += d[i];
        }
        return x;
    }
    T semiopenSum(int l, int r) {
        // [l,r)の半開区間
        return sum(r-1) - sum(l-1);
    }
};  // BIT<int> bit(N);

int main() {
    ll H, W, M;
    cin >> H >> W >> M;
    vector<int> col(W, H), row(H, W);
    rep(i, M) {
        int x, y;
        cin >> x >> y;
        --x; --y;
        chmin(col[y], x);
        chmin(row[x], y);
    }
    ll ans = 0;
    rep(i, col[0]) ans += row[i];
    rep(j, row[0]) ans += col[j];
    vector<vector<int>> A(H+1);
    rep(j, row[0]) A[col[j]].push_back(j);
    BIT<int> bit(W+1);
    rep(j, row[0]) bit.add(j, 1);
    rep(i, col[0]) {
        for (int a : A[i]) {
            bit.add(a, -1);            
        }
        ans -= bit.semiopenSum(0, row[i]);
    }
    cout << ans << '\n';
    return 0;
    // 重複, 境界, 条件, ll (1e5のnCr), 0, -, 1i, for s&g, debug
}
#include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define bug(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i) 
const int mod = 1e9+7;
const int mod1 = 998244353;
const ll inf = 1e14;
const int nax = 200005;
int H, W, M, x[nax], y[nax], L[nax], T[nax], a[nax];
vector<int> row[nax];
void MIN(int &a, int b){  
  a = min(a, b);
}
void update(int pos){
  while(pos <= W){
    a[pos]++;
    pos += pos&-pos;
  }
}
int sum(int pos){
  int now = 0;
  while(pos >= 1){
    now += a[pos];
    pos -= pos&-pos;
  }
 return now;
}
void solve()
 {
  cin>>H>>W>>M;
  for(int i = 1; i <= H; i++)
     L[i] = W + 1;
  for(int i = 1; i <= W; i++)
     T[i] = H + 1;
  for(int i = 1; i <= M; i++){
    cin>>x[i]>>y[i];
    MIN(L[x[i]], y[i]);
    MIN(T[y[i]], x[i]);
  }
  ll ans = 0;
  for(int i = 1; i <= W; i++){
    if(i < L[1])
      ans += T[i] - 1;
    else
      T[i] = 1;
    row[T[i]].pb(i);
  }
  for(int i = 1; i < T[1]; i++){
    ans += sum(L[i] - 1);
    for(int x : row[i])
       update(x);
  }
  cout<<ans;
 }
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
 /* int t;
  cin>>t;
  while(t--)*/
   solve();
  return 0;
}    
