#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
//#include <atcoder/all>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

vector<ll> b,bb;

ll sm(int id){
  ll res = 0;
  rep(i,id/1000) res+=bb[i];
  for(int i=id/1000*1000;i<id;i++) res+=b[i];
  return res;
}

int main(){
  ll H,W,M;
  cin >> H >> W >> M;
  vector<pair<ll,ll>> XY(M);
  rep(i,M) {
    cin >> XY[i].first >> XY[i].second;
    XY[i].first--;
    XY[i].second--;
  }
  vector<vector<ll>> A(W);
  rep(i,M){
    A[XY[i].second].pb(XY[i].first);
  }
  rep(i,W) sort(all(A[i]));
  ll ans = 0;
  b.assign(W,0);
  bb.assign((W+999)/1000,0);
  rep(i,W){
    if(A[i].empty()){
      ans += H;
    }
    else if(A[i][0]!=0){
      ans += A[i][0];
    }
    else break;
    //cout << ans << endl;
  }
  vector<vector<ll>> B(H);
  rep(i,M){
    B[XY[i].first].pb(XY[i].second);
  }
  rep(i,H) sort(all(B[i]));
  rep(i,H){
    if(!B[i].empty() && B[i][0]==0) break;
    ll x=W;
    if(!B[i].empty()) x=B[i][0];
    //cout << "x:"<<x << endl;
    rep(j,sz(B[i])){
      int k=B[i][j];
      if(b[k]==0){
        b[k]++;
        bb[k/1000]++;
      }
    }
    if(i==0){
      if(B[i].empty()){}
      else{
        int k=B[i][0];
        for(int kk=k;kk<W;kk++){
          if(b[kk]==0){
            b[kk]++;
            bb[kk/1000]++;
          }
        }
      }
    }
    ans += (sm(x));
    //cout << ans << endl;
  }
  cout << ans << endl;
  return 0;
}

#include <bits/stdc++.h>
#define gibon ios::sync_with_stdio(false); cin.tie(0);
#define fir first
#define sec second
#define pii pair<int, int>
#define pll pair<ll, ll>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
using namespace std;
int dx[4]={0, 1, 0, -1}, dy[4]={1, 0, -1 , 0};
const int mxN=200010;
const int mxM=1000010;
const ll MOD=1000000007;
const ll INF=100000000000001;
int H, W, M;
int X[mxN], Y[mxN];
vector <int> seg[4*mxN];
ll ans;
void init(int idx, int s, int e)
{
    if(s==e)
    {
        seg[idx].push_back(Y[s]);
        return;
    }
    int mid=(s+e)/2;
    init(2*idx, s, mid);
    init(2*idx+1, mid+1, e);
    int lcur=0, rcur=0;
    while(lcur!=mid-s+1 && rcur!=e-mid)
    {
        if(seg[2*idx][lcur]<seg[2*idx+1][rcur])
        {
            seg[idx].push_back(seg[2*idx][lcur]);
            lcur++;
        }
        else
        {
            seg[idx].push_back(seg[2*idx+1][rcur]);
            rcur++;
        }
    }
    while(lcur!=mid-s+1)
    {
        seg[idx].push_back(seg[2*idx][lcur]);
        lcur++;
    }
    while(rcur!=e-mid)
    {
        seg[idx].push_back(seg[2*idx+1][rcur]);
        rcur++;
    }
}
int solv(int idx, int s, int e, int str, int fin, int val)
{
    if(e<str || fin<s)  return 0;
    if(str<=s && e<=fin)
    {
        int sma = lower_bound(seg[idx].begin(), seg[idx].end(), val)-seg[idx].begin();
        return e-s+1-sma;
    }
    int mid=(s+e)/2;
    return solv(2*idx, s, mid, str, fin, val)+solv(2*idx+1, mid+1, e, str, fin, val);
}
int main()
{
    gibon
    cin >> H >> W >> M;
    for(int i=0;i<H;i++)    X[i]=W;
    for(int i=0;i<W;i++)    Y[i]=H;
    for(int i=0;i<M;i++)
    {
        int a, b;
        cin >> a >> b;
        a--; b--;
        X[a]=min(X[a], b);
        Y[b]=min(Y[b], a);
    }
    int minx=X[0], miny=Y[0];
    for(int i=0;i<Y[0];i++) ans+=X[i];
    for(int i=0;i<X[0];i++) ans+=Y[i];
    init(1, 0, X[0]-1);
    for(int i=0;i<Y[0];i++)
    {
        ans-=solv(1, 0, X[0]-1, 0, X[i]-1, i+1);
    }
    cout << ans;
}
