#include <bits/stdc++.h>
using namespace std;

typedef int_fast32_t int32;
typedef int_fast64_t int64;

const int32 inf = 1e9+7;
const int32 MOD = 1000000007;
const int64 llinf = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define all(obj) (obj).begin(),(obj).end()
#define rall(obj) (obj).rbegin(),(obj).rend()
#define fi first
#define se second
#define pb(a) push_back(a)
typedef pair<int32,int32> pii;
typedef pair<int64,int64> pll;

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) { a = b; return true; } return false;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) { a = b; return true; } return false;
}

template<typename T>
struct SegmentTree{
    typedef function<T(T,T)> F;
    int n;    //要素数
    F f;    //2項演算
    T e;    //単位元
    vector<T> dat;
    SegmentTree(int n_,F f,T e):f(f),e(e){
        init(n_);
        build();
    }
    SegmentTree(int n_,F f,T e,vector<T>& v):f(f),e(e){
        init(n_);
        build(n_,v);
    }
    void init(int n_){
        n=1;
        while(n<n_)n<<=1;
        dat.clear();
        dat.resize(n<<1, e);
    }
    void build(int n_,const vector<T>& v){
        for(int i=0;i<n_;++i)dat[n+i]=v[i];
        build();
    }
    void build(){
        for(int i=n-1;i>=1;--i){
            dat[i] = f(dat[i<<1],dat[i<<1|1]);
        }
    }
    void update(int k,const T& x){
        dat[k+=n]=x;
        while(k>>=1){
            dat[k] = f(dat[k<<1],dat[k<<1|1]);
        }
    }
    T query(int a,int b){
        T l=e,r=e;
        for(a+=n,b+=n;a<b;a>>=1,b>>=1){
            if(a&1)l=f(l,dat[a++]);
            if(b&1)r=f(dat[--b],r);
        }
        return f(l,r);
    }
    T operator[](const int &k) const {
        return dat[n+k];
    }
};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int64 h,w,m;
  cin >> h >> w >> m;
  vector<vector<int64>> ys(w),xs(h);
  REP(i,m){
    int64 y,x;
    cin >> y >> x;
    --y;--x;
    // chmin(ys[x],y);
    // chmin(xs[y],x);
    ys[x].emplace_back(y);
    xs[y].emplace_back(x);
  }
  REP(i,w){
    ys[i].emplace_back(h);
    sort(all(ys[i]));
  }
  REP(j,h){
    xs[j].emplace_back(w);
    sort(all(xs[j]));
  }

  int64 ans = 0;
  SegmentTree<int64> st(w+1,[](int64 a, int64 b){return a+b;},0);
  REP(i,xs[0][0])st.update(i,1);
  REP(y,h){
    for(auto x : xs[y])
      st.update(x,0);
    if(y < ys[0][0]){
      ans += xs[y][0];
      ans += st.query(xs[y][0],w);
    }else{
      ans += st.query(0,w);
    }
  }
  ANS(ans);
  return 0;
}
#include <bits/stdc++.h>
using namespace std;
 
#define rng(x) x.begin(), x.end()
#define maxi(x, y) x = max(x, (y))
#define mini(x, y) x = min(x, (y))
#define pb push_back
#define F first
#define S second
#define el '\n'
#define int long long
#define SZ(x) ((int)(x).size()) 
template<typename T>
istream&operator>>(istream&is,vector<T>&v){for(auto&it:v)is>>it;return is;}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
    return os << "(" << P.F << "," << P.S << ")"; }
template<class T> ostream& operator<<(ostream &os, vector<T> V) {
    os << "[ "; for(auto v : V) os << v << " "; return os << "]"; }
template<class T> ostream& operator<<(ostream &os, set<T> S){
    os << "{ "; for(auto s:S) os<<s<<" "; return os<<"}"; }
#ifndef ONLINE_JUDGE 
#define db(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define db(...)
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr<<name<<" : "<<arg1<<'\n';}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names,comma-names)<<" : "<<arg1<<" |";__f(comma+1, args...);}
typedef pair<int,int> pi; typedef vector<int> vi; typedef vector<vi> vvi;
 
/*-----------------------------Code Begins--------------------------------*/


class BIT{
public :
    int n;
    vi f;
    BIT(int n){
        this->n = n + 1000;
        f.assign(n, 0);
    }

    int get(int pos){
        int res = 0;
        for (; pos >= 0; pos = (pos & (pos + 1)) - 1){
            res += f[pos];
        }
        return res;
    }

    int get(int l, int r){
        return get(r) - get(l - 1);
    }

    void increase(int pos, int val){
        for (; pos < SZ(f); pos = (pos | (pos + 1))) {
            f[pos] += val;
        }
    }
};


void solve(){
    int n, m; cin>>n>>m;

    vi up(m, n), left(n, m);

    vi cols[n];

    int b; cin>>b;

    int l = m, d = n;

    while(b--){
        int i, j; cin>>i>>j;
        i--, j--;

        cols[i].pb(j);

        mini(up[j], i);
        mini(left[i], j);

        if(i == 0){
            mini(l, j);
        }
        if(j == 0){
            mini(d, i);
        }
    }

    int ans = 0;
    for(int j = 0; j < l; ++j){
        ans += up[j];
        assert(up[j] > 0);
    }

    db(ans, d, l);


    BIT bit(m);

    for(int j = l; j < m; ++j){
        bit.increase(j, 1);
    }
    
    for(int i = 0; i < d; ++i){
        ans += bit.get(0, left[i] - 1);
        for(int j : cols[i]){
            if(bit.get(j, j)){
                continue;
            }
            db(j);
            bit.increase(j, 1);
        }
    }

    cout<<ans<<el;
}
 
int32_t main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int T = 1;
    // cin>>T;
    while(T--){
        solve();
    }
    return 0;
}