#include <bits/stdc++.h>
#define int long long int
#define ll long long int
#define ld long double
#define getFaster ios_base::sync_with_stdio(false), cin.tie(nullptr)
#define rep(i, init, n) for (int i = init; i < (int)n; i++)
#define rev(i, n, init) for (int i = (int)n; i >= init; i--)
#define MOD1 1e9 + 7
#define MOD2 998244353
#define f first
#define s second
#define endl '\n'
#define pii pair<int, int>
#define tii tuple<int, int>
#define all(v) v.begin(), v.end()
#define mt make_tuple
#define precise(i) cout << fixed << setprecision(i)
#define codejam cout << "Case #" << ii + 1 << ": ";
#define impossible cout << "IMPOSSIBLE" << endl;
#define error(s) throw runtime_error(s)
#define prev prev1
std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
int myRand(int R)
{
     int val = rng() % R;
     assert(val >= 0);
     return val;
}

const long double PI = atan(1.0) * 4;
const int32_t INF32 = 2e9 + 7;
const int64_t INF64 = 3e18;
const int32_t LOG = 21;
const int32_t MOD = MOD1;

using namespace std;

//-------------------DEBUGGING-------------------------
void my_debugger(string s, int LINE_NUM) { cerr << endl; }
template <typename start, typename... end>
void my_debugger(string s, int LINE_NUM, start x, end... y)
{
     if (s.back() != ',')
     {
          s += ',';
          cerr << "LINE(" << LINE_NUM << "): ";
     }
     int i = s.find(',');
     cerr << s.substr(0, i) << " = " << x;
     s = s.substr(i + 1);
     if (!s.empty())
          cerr << ", ";
     my_debugger(s, LINE_NUM, y...);
}

#ifdef AJIT
#define debug(...) my_debugger(#__VA_ARGS__, __LINE__, __VA_ARGS__);
#else
#define debug(...) ;
#endif

//-----------------------------------------------------

int gcd(int a, int b, int& x, int& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    int x1, y1;
    int d = gcd(b, a % b, x1, y1);
    x = y1;
    y = x1 - y1 * (a / b);
    return d;
}

bool find_any_solution(int a, int b, int c, int &x0, int &y0, int &g) {
    g = gcd(abs(a), abs(b), x0, y0);
    if (c % g) {
        return false;
    }

    x0 *= c / g;
    y0 *= c / g;
    if (a < 0) x0 = -x0;
    if (b < 0) y0 = -y0;
    return true;
}

int table[200005] = {0};
void update(int i, int delta)
{
     while (i <= 200003)
     {
          table[i] += delta;
          i += (i & -i);
     }
}
int pref_sum(int i)
{
     int sum = 0;
     while (i > 0)
     {
          sum += table[i];
          i -= i & -i;
     }
     return sum;
}
int sum(int l, int r)
{
     if (l > r)
          return 0;
     return pref_sum(r) - pref_sum(l - 1);
}

int32_t main()
{
     getFaster;
     //files_init();
     int tests = 1;
     //cin >> tests;
     rep(ii, 0, tests)
     {
          int n,m;
          cin>>n>>m;
          int obs;
          cin>>obs;
          vector<pii> vals(obs);
          vector<int> row(n+1,m+1),col(m+1,n+1);
          rep(i,0,obs)
          {
               cin>>vals[i].f>>vals[i].s;
               int r,c;
               tie(r,c)=mt(vals[i].f,vals[i].s);
               row[r]=min(row[r],c);
               col[c]=min(col[c],r);
          }
          
          vector<vector<int>> data(m+2);
          int ans=0;
          rep(i,1,col[1])
          {
               if(i>n)break;
               int extend=row[i]-1;
               ans+=extend;
               data[1].push_back(i);
               data[extend+1].push_back(-i);
          }

          
          for(int ind=1;ind<=m;ind++)
          {
                vector<int>& temp=data[ind];
                rep(i,0,temp.size())
                {
                     int val=temp[i];
                     if(val<0)
                     update(-val,-1);
                     else
                     update(val,1);
                }
                if(pref_sum(1)==0)break;
                int cur=col[ind]-1;
                ans-=pref_sum(cur);
                ans+=cur;
          }
          cout<<ans<<endl;
     }     
     return 0;
}
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
#include <cfloat>
#include <iomanip>
using namespace std;
long long X[200000];
long long Y[200000];
long long min_X[200000];
long long min_Y[200000];

int sqrtN = 450;
struct SqrtDecomposition{
    int N, K;
    vector <long long> data;
    vector <long long> bucketSum;

    SqrtDecomposition(int n){
        N = n;
        K = (N + sqrtN - 1) / sqrtN;
        data.assign(N, 0);
        bucketSum.assign(K, 0);
    }

    void add(int x, int y){
        data[x] += y;
        bucketSum[x / sqrtN] += y;
    }

    long long getSum(int x, int y){
        long long ans = 0;
        if(y - x < sqrtN){
            for(int i = x; i < y; i++){
                ans += data[i];
            }
            return ans;
        }
        for(int i = x / sqrtN + 1; i < y / sqrtN; i++){
            ans += bucketSum[i];
        }

        for(int i = x; i < (x / sqrtN + 1) * sqrtN; i++){
            ans += data[i];
        }
        for(int i = y / sqrtN * sqrtN; i < y; i++){
            ans += data[i];
        }
        return ans;
    }

};

int main(){
  int H;
  int W;
  int M;
  cin >> H >> W >> M;

  for(int i = 0; i < M; i++){
    cin >> X[i] >> Y[i];
  }

  long long ans = 0;
  for(int i = 0; i < H; i++){
    min_Y[i] = W;
  }
  for(int i = 0; i < W; i++){
    min_X[i] = H;
  }
  for(int i = 0; i < M; i++){
    min_Y[X[i] - 1] = min(min_Y[X[i] - 1], Y[i] - 1);
    min_X[Y[i] - 1] = min(min_X[Y[i] - 1], X[i] - 1);
  }
  for(int i = 0; i < min_X[0]; i++){
    ans += min_Y[i];
  }

  SqrtDecomposition sq(H);
  for(int i = 0; i < min_X[0]; i++){
    sq.add(i, 1);
  }
  vector <pair<long long, long long> > YX_vec;
  for(int i = 0; i < min_X[0]; i++){
    YX_vec.push_back(make_pair(min_Y[i], i));
  }
  sort(YX_vec.begin(), YX_vec.end());
  int min_Y_vec_ind = 0;
  for(int i = 0; i < min_Y[0]; i++){
      while(min_Y_vec_ind < min_X[0] && YX_vec[min_Y_vec_ind].first <= i){
        if(YX_vec[min_Y_vec_ind].first == i){
          sq.add(YX_vec[min_Y_vec_ind].second, -1);
        }
        min_Y_vec_ind ++;
      }
      ans += min_X[i] - sq.getSum(0, min_X[i]);
  }
  cout << ans << endl;
  return 0;
}
