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;
int parent[3001][6001][2], size[3001][6001];
int visited[3001][6001], vidx;
char marked[3001][6001], tleft[3001][6001], tright[3001][6001];
char tmidl[3001][6001], tmidr[3001][6001];
char ttl1, ttr1, ttmr1, ttml1, ttl2, ttr2, ttml2, ttmr2;
int M, N, Q, i, j, k, ii, jj, tii, tjj, tmpx, tmpy, ans, res;
int drow[8] = {-1, 0, +1, 0, -1, -1, +1, +1};
int dcol[8] = {0, +1, 0, -1, -1, +1, -1, +1};
void Find(int x, int y, int& tx, int& ty) {
  tx = x;
  ty = y;
  while (parent[tx][ty][0] >= 0) {
    tmpx = parent[tx][ty][0];
    tmpy = parent[tx][ty][1];
    tx = tmpx;
    ty = tmpy;
  }
  while (x != tx || y != ty) {
    tmpx = parent[x][y][0];
    tmpy = parent[x][y][1];
    parent[x][y][0] = tx;
    parent[x][y][1] = ty;
    x = tmpx;
    y = tmpy;
  }
}
void Union(int x, int y, int u, int v) {
  int tx, ty, tu, tv;
  Find(x, y, tx, ty);
  Find(u, v, tu, tv);
  if (tx == tu && ty == tv) return;
  if (size[tx][ty] >= size[tu][tv]) {
    parent[tu][tv][0] = tx;
    parent[tu][tv][1] = ty;
    tleft[tx][ty] |= tleft[tu][tv];
    tright[tx][ty] |= tright[tu][tv];
    tmidl[tx][ty] |= tmidl[tu][tv];
    tmidr[tx][ty] |= tmidr[tu][tv];
    size[tx][ty] += size[tu][tv];
    if (0)
      fprintf(stderr, "new root: %d %d (%d %d %d %d)\n", tx + 1, ty + 1,
              tleft[tx][ty], tright[tx][ty], tmidl[tx][ty], tmidr[tx][ty]);
  } else {
    parent[tx][ty][0] = tu;
    parent[tx][ty][1] = tv;
    tleft[tu][tv] |= tleft[tx][ty];
    tright[tu][tv] |= tright[tx][ty];
    tmidl[tu][tv] |= tmidl[tx][ty];
    tmidr[tu][tv] |= tmidr[tx][ty];
    size[tu][tv] += size[tx][ty];
    if (0)
      fprintf(stderr, "new root: %d %d (%d %d %d %d)\n", tu + 1, tv + 1,
              tleft[tu][tv], tright[tu][tv], tmidl[tu][tv], tmidr[tu][tv]);
  }
}
void ProcessCell(int i, int j) {
  marked[i][j] = marked[i][j + N] = 1;
  vidx++;
  visited[i][j] = vidx;
  ttl1 = tleft[i][j];
  ttr1 = tright[i][j];
  ttml1 = tmidl[i][j];
  ttmr1 = tmidr[i][j];
  ttl2 = tleft[i][j + N];
  ttr2 = tright[i][j + N];
  ttml2 = tmidl[i][j + N];
  ttmr2 = tmidr[i][j + N];
  for (k = 0; k < 8; k++) {
    ii = i + drow[k];
    if (ii < 0 || ii >= M) continue;
    jj = (j + dcol[k] + 2 * N) % (2 * N);
    if (marked[ii][jj]) {
      Find(ii, jj, tii, tjj);
      ttl1 |= tleft[tii][tjj];
      ttr1 |= tright[tii][tjj];
      ttml1 |= tmidl[tii][tjj];
      ttmr1 |= tmidr[tii][tjj];
      visited[tii][tjj] = vidx;
    }
  }
  for (k = 0; k < 8; k++) {
    ii = i + drow[k];
    if (ii < 0 || ii >= M) continue;
    jj = (j + N + dcol[k] + 2 * N) % (2 * N);
    if (marked[ii][jj]) {
      Find(ii, jj, tii, tjj);
      ttl2 |= tleft[tii][tjj];
      ttr2 |= tright[tii][tjj];
      ttml2 |= tmidl[tii][tjj];
      ttmr2 |= tmidr[tii][tjj];
      if (visited[tii][tjj] == vidx) {
        ttl2 |= ttl1;
        ttr2 |= ttr1;
        ttml2 |= ttml1;
        ttmr2 |= ttmr1;
      }
    }
  }
  if (0)
    fprintf(stderr, "process %d %d: (%d %d %d %d) (%d %d %d %d)\n", i + 1,
            j + 1, ttl1, ttr1, ttml1, ttmr1, ttl2, ttr2, ttml2, ttmr2);
  if ((!ttl1 || !ttr1 || !ttml1 || !ttmr1) &&
      (!ttl2 || !ttr2 || !ttml2 || !ttmr2)) {
    parent[i][j][0] = parent[i][j][1] = parent[i][j + N][0] =
        parent[i][j + N][1] = -1;
    size[i][j] = size[i][j + N] = 1;
    if (0) {
      fprintf(stderr, "new elem: %d %d (%d %d %d %d)\n", i + 1, j + 1,
              tleft[i][j], tright[i][j], tmidl[i][j], tmidr[i][j]);
      fprintf(stderr, "new elem: %d %d (%d %d %d %d)\n", i + 1, j + 1 + N,
              tleft[i][j + N], tright[i][j + N], tmidl[i][j + N],
              tmidr[i][j + N]);
    }
    for (k = 0; k < 8; k++) {
      ii = i + drow[k];
      if (ii < 0 || ii >= M) continue;
      jj = (j + dcol[k] + 2 * N) % (2 * N);
      if (marked[ii][jj]) Union(i, j, ii, jj);
    }
    for (k = 0; k < 8; k++) {
      ii = i + drow[k];
      if (ii < 0 || ii >= M) continue;
      jj = (j + N + dcol[k] + 2 * N) % (2 * N);
      if (marked[ii][jj]) Union(i, j + N, ii, jj);
    }
    if (0) fprintf(stderr, "ok %d %d\n", i + 1, j + 1);
    ans++;
  } else
    marked[i][j] = marked[i][j + N] = 0;
}
int main() {
  scanf("%d %d %d", &M, &N, &Q);
  for (i = 0; i < M; i++)
    for (j = 0; j < 2 * N; j++) parent[i][j][0] = parent[i][j][1] = -1;
  memset(marked, 0, sizeof(marked));
  memset(tleft, 0, sizeof(tleft));
  memset(tright, 0, sizeof(tright));
  memset(tmidl, 0, sizeof(tmidl));
  memset(tmidr, 0, sizeof(tmidr));
  for (i = 0; i < M; i++)
    tleft[i][0] = tright[i][2 * N - 1] = tmidl[i][N - 1] = tmidr[i][N] = 1;
  ans = vidx = 0;
  while (Q--) {
    scanf("%d %d", &i, &j);
    i--;
    j--;
    ProcessCell(i, j);
  }
  printf("%d\n", ans);
  return 0;
}
