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 A = 3e3 + 5;
const int N = 2e7 + 6;
inline int Get() {
  char ch;
  while ((ch = getchar()) < '0' || ch > '9')
    ;
  int Num = ch - '0';
  while ((ch = getchar()) >= '0' && ch <= '9')
    Num = (Num << 3) + (Num << 1) + ch - '0';
  return Num;
}
int nR, nC, n2C, n, fa[N], mark[A][A << 1], ans;
int gox[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
int goy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
inline int find(int x) { return fa[x] == x ? x : fa[x] = find(fa[x]); }
int main() {
  nR = Get(), nC = Get(), n2C = nC * 2, n = Get();
  for (int i = 0; i < nR * n2C; ++i) fa[i] = i;
  for (int i = 1; i <= n; ++i) {
    int x0 = Get() - 1, y0 = Get() - 1, x1 = x0, y1 = y0 + nC;
    bool flag = true;
    for (int k0 = 0; k0 < 8; ++k0) {
      int nx0 = x0 + gox[k0], ny0 = (y0 + goy[k0] + n2C) % n2C;
      if (nx0 < 0 || nx0 >= nR) continue;
      if (!mark[nx0][ny0]) continue;
      int id0 = find(nx0 * n2C + ny0);
      for (int k1 = 0; k1 < 8; ++k1) {
        int nx1 = x1 + gox[k1], ny1 = (y1 + goy[k1] + n2C) % n2C;
        if (nx1 < 0 || nx1 >= nR) continue;
        if (!mark[nx1][ny1]) continue;
        int id1 = find(nx1 * n2C + ny1);
        if (id0 == id1) {
          flag = false;
          break;
        }
      }
      if (!flag) break;
    }
    if (flag) {
      ++ans;
      for (int k = 0; k < 8; ++k) {
        int nx = x0 + gox[k], ny = (y0 + goy[k] + n2C) % n2C;
        if (nx < 0 || nx >= nR) continue;
        if (!mark[nx][ny]) continue;
        fa[find(nx * n2C + ny)] = find(x0 * n2C + y0);
      }
      for (int k = 0; k < 8; ++k) {
        int nx = x1 + gox[k], ny = (y1 + goy[k] + n2C) % n2C;
        if (nx < 0 || nx >= nR) continue;
        if (!mark[nx][ny]) continue;
        fa[find(nx * n2C + ny)] = find(x1 * n2C + y1);
      }
      mark[x0][y0] = mark[x1][y1] = true;
    }
  }
  printf("%d\n", ans);
}
