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>
const int N = 3005;
int c[8][2] = {1, 0, 0, 1, -1, 0, 0, -1, 1, 1, -1, -1, 1, -1, -1, 1};
int f[(N * 2) * N];
bool u[N][N + N];
int find(int x) {
  if (x != f[x]) f[x] = find(f[x]);
  return f[x];
}
int main() {
  int R, C, n, i, j, ret = 0;
  scanf("%d%d%d", &R, &C, &n);
  for (i = 0; i < R * (C + C) + 10; i++) f[i + 1] = i + 1;
  while (n--) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (C == 1) continue;
    x--;
    y--;
    int flag = 0;
    for (i = 0; i < 8; i++) {
      int X1 = x + c[i][0];
      int Y1 = (y + c[i][1] + 2 * C) % (C + C);
      for (j = 0; j < 8; j++) {
        int X2 = x + c[j][0];
        int Y2 = (y + C + c[j][1]) % (C + C);
        if (X1 >= 0 && X1 < R && X2 >= 0 && X2 < R && u[X1][Y1] && u[X2][Y2]) {
          int d1 = X1 * (C + C) + Y1 + 1;
          int d2 = X2 * (C + C) + Y2 + 1;
          int f1 = find(d1), f2 = find(d2);
          if (f1 == f2) {
            i = j = 8;
            flag = 1;
            break;
          }
        }
      }
    }
    if (!flag) {
      u[x][y] = u[x][(y + C) % (C + C)] = true;
      for (i = 0; i < 8; i++) {
        int X1 = x + c[i][0];
        int Y1 = (y + c[i][1] + 2 * C) % (C + C);
        int X2 = x + c[i][0];
        int Y2 = (y + C + c[i][1]) % (C + C);
        if (X1 >= 0 && X1 < R && u[X1][Y1]) {
          int d1 = X1 * (C + C) + Y1 + 1;
          int d2 = x * (C + C) + y + 1;
          int f1 = find(d1), f2 = find(d2);
          if (f1 != f2) f[f2] = f1;
        }
        if (X2 >= 0 && X2 < R && u[X2][Y2]) {
          int d1 = X2 * (C + C) + Y2 + 1;
          int d2 = x * (C + C) + (y + C) % (C + C) + 1;
          int f1 = find(d1), f2 = find(d2);
          if (f1 != f2) f[f2] = f1;
        }
      }
      ret++;
    }
  }
  printf("%d\n", ret);
  return 0;
}
