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 r, c, n;
bool land[3010][6010];
const int pos[8][2] = {{-1, 0}, {-1, -1}, {0, -1}, {1, -1},
                       {1, 0},  {1, 1},   {0, 1},  {-1, 1}};
inline bool inarea(int x, int y) {
  return x > 0 && x <= r && y > 0 && y <= c * 2;
}
inline int id(int x, int y) { return (x - 1) * (c * 2) + y; }
int fa[18000010], cnt = 0;
inline int getf(int x) { return fa[x] == x ? x : fa[x] = getf(fa[x]); }
inline void merge(int a, int b) {
  if (getf(a) != getf(b)) fa[getf(a)] = getf(b);
}
int main() {
  scanf("%d%d%d", &r, &c, &n);
  for (int i = 1; i <= 2 * r * c; i++) fa[i] = i;
  if (c == 1) {
    puts("0");
    return 0;
  }
  for (int i = 1, ti, tj; i <= n; i++) {
    scanf("%d%d", &ti, &tj);
    bool flag = 1;
    for (int j = 0; j < 8; j++) {
      if (inarea(ti + pos[j][0], tj + pos[j][1]) &&
          land[ti + pos[j][0]][tj + pos[j][1]]) {
        for (int k = 0; k < 8; k++) {
          if (inarea(ti + pos[k][0], tj + pos[k][1] + c) &&
              land[ti + pos[k][0]][tj + pos[k][1] + c] &&
              getf(id(ti + pos[j][0], tj + pos[j][1])) ==
                  getf(id(ti + pos[k][0], tj + pos[k][1] + c))) {
            flag = 0;
            break;
          }
        }
        if (!flag) break;
      }
    }
    if (flag) {
      ++cnt;
      land[ti][tj] = 1;
      land[ti][tj + c] = 1;
      for (int j = 0; j < 8; j++)
        if (inarea(ti + pos[j][0], tj + pos[j][1]) &&
            land[ti + pos[j][0]][tj + pos[j][1]])
          merge(id(ti, tj), id(ti + pos[j][0], tj + pos[j][1]));
      for (int j = 0; j < 8; j++)
        if (inarea(ti + pos[j][0], tj + pos[j][1] + c) &&
            land[ti + pos[j][0]][tj + pos[j][1] + c])
          merge(id(ti, tj + c), id(ti + pos[j][0], tj + pos[j][1] + c));
    }
  }
  printf("%d\n", cnt);
  return 0;
}
