#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>
#include <bitset>
//#include <atcoder/all>

using namespace std;
//using namespace atcoder;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

struct BIT {    // 1-indexed
    int n;
    vector<long long> bit;

    BIT(int n) : n(n), bit(n + 1, 0) {}

    void add(int i, int w){
        for(int x = i; x <= n; x += x & -x) bit[x] += w;
    }

    long long sum(int i){ // sum of [1, i]
        int ret = 0;
        for(int x = i; x > 0; x -= x &- x) ret += bit[x];
        return ret;
    }

    long long sum(int l, int r){  // sum of [l, r]
        return sum(r) - sum(l - 1);
    }
};

void solve() {
    ll h, w, m;
    cin >> h >> w >> m;
    vll x(m), y(m);
    rep(i, m) {
        cin >> x[i] >> y[i];
        --x[i], --y[i];
    }
    vector<set<ll>> sety(w), setx(h);
    rep(i, w) sety[i].insert(h);
    rep(i, h) setx[i].insert(w);
    rep(i, m) {
        sety[y[i]].insert(x[i]);
        setx[x[i]].insert(y[i]);
    }
    ll ans = 0;
    for(ll j = 0; j < *setx[0].begin(); ++j) {
        ans += *sety[j].begin();
//        cout << ans << endl;
    }
    set<pll> setob;
    rep(i, m) setob.emplace(x[i], y[i]);
    for(ll j = *setx[0].begin()+1; j < w; ++j) {
        setob.emplace(0, j);
    }
    BIT bit(w+2);
    for(ll i = 0; i < *sety[0].begin(); ++i) {
        ll r = *setx[i].begin();
        ll cntob = bit.sum(r);
//        cout << i << ' ' << cntob << ' ' << r << endl;
        ans += cntob;
        while(!setob.empty() && setob.begin()->first <= i) {
            ll j = setob.begin()->second;
            setob.erase(setob.begin());
            ll now = bit.sum(j+1, j+1);
            if(now == 0) bit.add(j+1, 1);
        }
    }
    cout << ans << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define ep emplace
#define epb emplace_back
#define scll static_cast<long long> 
#define sz(x) static_cast<int>((x).size())
#define pfll(x) printf("%lld\n", x)
#define ci(x) cin >> x
#define ci2(x, y) cin >> x >> y
#define ci3(x, y, z) cin >> x >> y >> z
#define co(x) cout << x << endl
#define co2(x, y) cout << x << " " << y << endl
#define co3(x, y, z) cout << x << " " << y << " " << z << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> PQ;
typedef priority_queue<int, vector<int>, greater<int>> PQG;
typedef priority_queue<P> PQP;
typedef priority_queue<P, vector<P>, greater<P>> PQPG;

const int MAX_N = 2e5, MOD = 1e9 + 7, INF = 1e9;
int h, w, m;
int mh[MAX_N], mw[MAX_N];

const int ST_SIZE = (1 << 20) - 1;
vector<int> dat[ST_SIZE];

void init(int k, int l, int r) {
    if (r - l == 1) dat[k].push_back(mw[l]);
    else {
        int lch = k * 2 + 1, rch = k * 2 + 2;
        init(lch, l, (l + r) / 2);
        init(rch, (l + r) / 2, r);
        dat[k].resize(r - l);

        merge(dat[lch].begin(), dat[lch].end(),
              dat[rch].begin(), dat[rch].end(), dat[k].begin());
    }
}

int query(int i, int j, int x, int k, int l, int r) {
    if (j <= l || r <= i) return 0;
    else if (i <= l && r <= j) {
        return upper_bound(dat[k].begin(), dat[k].end(), x) -
               dat[k].begin();
    }
    else {
        int lc = query(i, j, x, k * 2 + 1, l, (l + r) / 2);
        int rc = query(i, j, x, k * 2 + 2, (l + r) / 2, r);
        return lc + rc;
    }
}

int main() {
    ci3(h, w, m);
    fill(mh, mh + w, h);
    fill(mw, mw + h, w);

    rep(i, m) {
        int x, y;
        ci2(x, y);
        mh[y - 1] = min(mh[y - 1], x - 1);
        mw[x - 1] = min(mw[x - 1], y - 1);
    }
    ll ans = 0;
    rep(i, mh[0]) ans += mw[i];

    init(0, 0, mh[0]);
    for (int i = 1; i < mw[0]; i++) {
        ans += query(1, min(mh[i], mh[0]), i - 1, 0, 0, mh[0]);
        ans += max(mh[i] - mh[0], 0);
    }
    co(ans);
    return 0;
}
