#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long int
#define mod 1000000007
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);

int main() {
    FIO;
    int t,n,i,j;
    cin>>n;
    int x[n];
    int y[n];
    for(i=0;i<n;i++){
        cin>>x[i]>>y[i];
    }
    int cnt=0;
    for(i=0;i<n-1;i++){
        for(j=i+1;j<n;j++){
            float slope = (float)(y[j]-y[i])/(float)(x[j]-x[i]); 
            if(slope>=-1 && slope<=1)
                cnt++;
        }
    }
    
    cout<<cnt;
        
      
    
    
    return 0;
}
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define ROF(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define REP(i, n) FOR(i, 0, (n)-1)
#define sqr(x) ((x) * (x))
#define all(x) (x).begin(), (x).end()
#define reset(x, y) memset(x, y, sizeof(x))
#define uni(x) (x).erase(unique(all(x)), (x).end())
#define BUG(x) cerr << #x << " = " << (x) << endl
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define _1 first
#define _2 second
#define chkmin(a, b) a = min(a, b)
#define chkmax(a, b) a = max(a, b)

const int maxn = 212345;

int h, w, m;
int reach[maxn], fen[maxn];
bool vis[maxn];
vector<int> G[maxn];

void add(int x, int v) {
  while (x <= w) {
    fen[x] += v;
    x += x & -x;
  }
}

int query(int x) {
  int ret = 0;
  while (x > 0) {
    ret += fen[x];
    x -= x & -x;
  }
  return ret;
}

int main() {
#ifdef ONLINE_JUDGE
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#endif
  cin >> h >> w;
  FOR(i, 1, h) reach[i] = w;
  cin >> m;
  while (m--) {
    int x, y; cin >> x >> y;
    G[x].eb(y);
    chkmin(reach[x], y - 1);
  }
  ll ans = 0;
  bool f = true;
  ans += reach[1];
  FOR(i, 1, reach[1]) add(i, 1), vis[i] = true;
  FOR(i, 2, h) {
    for (auto y : G[i]) if (vis[y]) {
      add(y, -1);
      vis[y] = false;
    }
    if (!vis[1]) f = false;
    ans += reach[i] * f + query(w) - query(f ? reach[i] : 0);
  }
  cout << ans;
}
