#include <bits/stdc++.h>

using namespace std;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define RREP(i, n) for(int i=(n);i>=0;--i)
#define FOR(i, a, n) for (int i=(a); i<(n); ++i)
#define RFOR(i, a, b) for(int i=(a);i>=(b);--i)


#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl;

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if (i) os << " ";
    os << v[i];
  }
  return os;
}

template <class T>
void debug(const vector<T> &v) {
  cout << "[";
  REP(i, SZ(v)) {
    if(i) cout << ", ";
    cout << v[i];
  }
  cout << "]" << endl;
}

template<class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  return os << p.first << " " << p.second;
}

template <class T, class U>
void debug(const pair<T, U> &p) {
  cout << "(" << p.first << " " << p.second << ")" << endl;
}

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

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const ll MOD998 = 998244353;
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;
const int inf = INT_MIN;
const ll linf = LLONG_MIN;
const ld eps = 1e-9;


template<int m>
struct mint {
  int x;

  mint(ll x = 0) : x(((x % m) + m) % m) {}

  mint operator-() const { return x ? m - x : 0; }

  mint &operator+=(mint r) {
    if ((x += r.x) >= m) x -= m;
    return *this;
  }

  mint &operator-=(mint r) {
    if ((x -= r.x) < 0) x += m;
    return *this;
  }

  mint &operator*=(mint r) {
    x = ((ll) x * r.x) % m;
    return *this;
  }

  mint inv() const { return pow(m - 2); }

  mint &operator/=(mint r) { return *this *= r.inv(); }

  friend mint operator+(mint l, mint r) { return l += r; }

  friend mint operator-(mint l, mint r) { return l -= r; }

  friend mint operator*(mint l, mint r) { return l *= r; }

  friend mint operator/(mint l, mint r) { return l /= r; }

  mint pow(ll n) const {
    mint ret = 1, tmp = *this;
    while (n) {
      if (n & 1) ret *= tmp;
      tmp *= tmp, n >>= 1;
    }
    return ret;
  }

  friend bool operator==(mint l, mint r) { return l.x == r.x; }

  friend bool operator!=(mint l, mint r) { return l.x != r.x; }

  friend ostream &operator<<(ostream &os, mint a) {
    return os << a.x;
  }

  friend istream &operator>>(istream &is, mint &a) {
    ll x;
    is >> x;
    a = x;
    return is;
  }
};

using Int = mint<MOD>;


template<typename T>
struct BIT {
  vector<T> bit;
  int sz;

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

  void add(int i, T x) {
    i += 1;
    while (i < sz) {
      bit[i] += x;
      i += i & -i;
    }
  }

  T sum(int i) {
    i += 1;
    T s = 0;
    while (i > 0) {
      s += bit[i];
      i -= i & -i;
    }
    return s;
  }
};


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int h, w, m; cin >> h >> w >> m;
  vi x(m), y(m);

  vi mir(h, w), mic(w, h);
  REP(i, m) {
    cin >> x[i] >> y[i];
    x[i]--;
    y[i]--;
    chmin(mir[x[i]], y[i]);
    chmin(mic[y[i]], x[i]);
  }

  int mar = mic[0], mac = mir[0];
  ll ans = 0;
  REP(i, mar) {
    ans += mir[i];
  }
  REP(i, mac) {
    ans += mic[i];
  }

  vector<P> v;
  REP(i, mar) {
    v.emplace_back(mir[i], i);
  }
  sort(ALL(v));

  BIT<int> bit(h+1);
  REP(i, mar) {
    bit.add(i, 1);
  }


  int pos = 0;
  REP(i, mac) {
    while(pos < mar && v[pos].first == i) {
      bit.add(v[pos].second, -1);
      pos++;
    }

    if(mic[i] != 0) ans -= bit.sum(mic[i]-1);
  }
  cout << ans << endl;


  return 0;
}




























































#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define MOD 1000000007
#define MAXN 200000

int ft[MAXN + 3];

void update(int idx, int val) {
    while (idx <= MAXN) {
        ft[idx] += val;
        idx += (idx & -idx);
    }
}

int query(int idx) {
    int result = 0;
    while (idx > 0) {
        result += ft[idx];
        idx -= (idx & -idx);
    }

    return result;
}

int H, W, N, firstBlockRight, firstBlockBelow;
vector<int> blockAtColumn[MAXN + 3];
bool seen[MAXN + 3];
LL answer;

int main() {
    scanf("%d%d%d", &H, &W, &N);

    firstBlockRight = W + 1;
    firstBlockBelow = H + 1;
    for (int i = 1; i <= N; i++) {
        int row, col;
        scanf("%d%d", &row, &col);

        if (row == 1) {
            firstBlockRight = min(firstBlockRight, col);
        }

        if (col == 1) {
            firstBlockBelow = min(firstBlockBelow, row);
        }

        blockAtColumn[col].push_back(row);
    }

    memset(ft, 0, sizeof(ft));
    memset(seen, false, sizeof(seen));

    answer = 0;
    for (int col = 1; col <= W; col++) {
        sort(blockAtColumn[col].begin(), blockAtColumn[col].end());

        for (auto row: blockAtColumn[col]) {
            if (!seen[row]) {
                seen[row] = true;
                update(row, 1);
            }
        }

        if (col < firstBlockRight) {
            if (blockAtColumn[col].empty()) {
                answer += H;
            } else {
                int r = blockAtColumn[col][0];
                if (r < firstBlockBelow) {
                    int cntBlocked = query(firstBlockBelow - 1) - query(r - 1);
                    answer += (firstBlockBelow - 1 - cntBlocked);
                } else {
                    answer += (r - 1);
                }
            }
        } else {
            int cntBlocked = query(firstBlockBelow - 1);
            answer += (firstBlockBelow - 1 - cntBlocked);
        }
    }

    printf("%lld\n", answer);
}
