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];
char marked[3001][6001], tleft[3001][6001], tright[3001][6001], ttleft, ttright;
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];
    size[tx][ty] += size[tu][tv];
  } else {
    parent[tx][ty][0] = tu;
    parent[tx][ty][1] = tv;
    tleft[tu][tv] |= tleft[tx][ty];
    tright[tu][tv] |= tright[tx][ty];
    size[tu][tv] += size[tx][ty];
  }
}
int ProcessCell(int i, int j, int test_result) {
  if (test_result == 0) {
    ttleft = tleft[i][j];
    ttright = tright[i][j];
    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);
        ttleft |= tleft[tii][tjj];
        ttright |= tright[tii][tjj];
      }
    }
    if (!ttleft || !ttright) test_result = 1;
  }
  if (test_result) {
    marked[i][j] = 1;
    parent[i][j][0] = parent[i][j][1] = -1;
    size[i][j] = 1;
    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);
    }
    ans++;
  }
  return test_result;
}
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));
  for (i = 0; i < M; i++) tleft[i][0] = tright[i][2 * N - 1] = 1;
  ans = 0;
  while (Q--) {
    scanf("%d %d", &i, &j);
    i--;
    j--;
    res = ProcessCell(i, j, 0);
    if (res) ProcessCell(i, j + N, 1);
  }
  printf("%d\n", ans >> 1);
  return 0;
}
