2 5 10
2 2
1 1
1 4
2 1
1 2
1 5
2 4
2 5
1 3
2 3
 2 2 2
1 1
2 2
 3 3 9
1 1
1 2
1 3
2 1
2 2
2 3
3 1
3 2
3 3
 7 5 35
5 3
3 5
1 1
2 5
6 4
7 2
5 1
3 4
6 5
7 3
4 1
2 2
4 2
2 4
4 3
3 3
6 1
1 2
4 5
1 3
2 1
5 5
7 5
7 1
6 2
1 4
1 5
3 2
4 4
5 2
2 3
6 3
7 4
5 4
3 1
 1 5 4
1 1
1 2
1 4
1 5
 1 1 1
1 1
 5 7 21
4 4
4 5
5 5
5 6
5 7
5 1
5 2
4 2
3 2
3 1
3 7
3 6
2 6
1 6
1 7
1 1
1 2
1 3
1 4
2 4
3 4
 2 1 1
1 1
 2 2 4
2 1
1 1
1 2
2 2
 3000 3000 1
2222 738
 5 7 35
1 2
2 3
5 1
5 7
4 4
5 3
3 1
2 6
4 5
2 7
4 1
2 1
2 2
1 7
5 6
3 6
4 6
1 6
1 1
3 3
3 4
4 2
2 5
5 5
3 5
2 4
1 5
1 3
4 3
5 4
1 4
3 7
4 7
3 2
5 2
 5 4 1
4 1
 3 4 12
2 3
3 2
2 2
2 1
1 2
3 1
1 4
1 3
3 3
2 4
3 4
1 1
 3 3 3
1 1
2 2
3 3

8
 1
 6
 26
 4
 0
 20
 0
 2
 1
 28
 1
 9
 3

#include <bits/stdc++.h>
using namespace std;
struct coord {
  int x, y;
} np;
int lnum[300000], vis[3005][3005], mvs[15][5], nnum = 1, totes, cols, rows, col,
                                               row, recs;
queue<coord> vi;
bool kit;
vector<bitset<3005> > viser(300000);
int tr(int num) {
  if (num > cols) return 1;
  if (num <= 0) return cols;
  return num;
}
void bfs(int x, int y, int nval, int lval) {
  np.x = x;
  np.y = y;
  vi.push(np);
  vis[x][y] = nval;
  if (viser[nval][x] == false) {
    viser[nval][x] = true;
    lnum[nval]++;
  }
  while (!vi.empty()) {
    x = vi.front().x;
    y = vi.front().y;
    vi.pop();
    for (int j = 1; j <= 8; j++) {
      if (vis[tr(x + mvs[j][1])][y + mvs[j][2]] == lval) {
        np.x = tr(x + mvs[j][1]);
        np.y = y + mvs[j][2];
        vi.push(np);
        vis[x][y] = nval;
        if (viser[nval][x] == false) {
          viser[nval][x] = true;
          lnum[nval]++;
        }
      }
    }
  }
}
int main() {
  mvs[1][1] = -1;
  mvs[2][1] = -1;
  mvs[3][1] = -1;
  mvs[4][1] = 1;
  mvs[5][1] = 1;
  mvs[6][1] = 1;
  mvs[7][1] = 0;
  mvs[8][1] = 0;
  mvs[1][2] = -1;
  mvs[2][2] = 0;
  mvs[3][2] = 1;
  mvs[4][2] = -1;
  mvs[5][2] = 0;
  mvs[6][2] = 1;
  mvs[7][2] = 1;
  mvs[8][2] = -1;
  scanf("%d%d%d", &rows, &cols, &recs);
  for (int i = 1; i <= recs; i++) {
    scanf("%d%d", &row, &col);
    for (int j = 1; j <= 8; j++) {
      if ((vis[tr(col + mvs[j][1])][row + mvs[j][2]] < vis[col][row] &&
           vis[tr(col + mvs[j][1])][row + mvs[j][2]]) ||
          (vis[tr(col + mvs[j][1])][row + mvs[j][2]] && vis[col][row] == 0)) {
        vis[col][row] = vis[tr(col + mvs[j][1])][row + mvs[j][2]];
        if (viser[vis[col][row]][col] == false) {
          viser[vis[col][row]][col] = true;
          lnum[vis[col][row]]++;
        }
      }
    }
    if (vis[col][row]) {
      kit = true;
      for (int j = 1; j <= 8; j++) {
        if (vis[tr(col + mvs[j][1])][row + mvs[j][2]] == vis[col][row] &&
            lnum[vis[col][row]] == cols) {
          kit = false;
        }
      }
      if (!kit) {
        viser[vis[col][row]][col] = false;
        lnum[vis[col][row]]--;
        vis[col][row] = 0;
      } else {
        for (int j = 1; j <= 8; j++) {
          if (vis[tr(col + mvs[j][1])][row + mvs[j][2]] > vis[col][row]) {
            bfs(tr(col + mvs[j][1]), row + mvs[j][2], vis[col][row],
                vis[tr(col + mvs[j][1])][row + mvs[j][2]]);
          }
        }
        totes++;
      }
    } else {
      vis[col][row] = nnum;
      nnum++;
      totes++;
    }
  }
  printf("%d\n", totes);
  return 0;
}
