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>
char ch;
inline void read(int &x) {
  x = 0;
  ch = getchar();
  while (ch <= 32) ch = getchar();
  while (ch > 32) x = x * 10 + ch - 48, ch = getchar();
};
int r, c, c1, n;
int fa[3005 * 6005];
inline int getfa(int x) { return fa[x] ? fa[x] = getfa(fa[x]) : x; }
bool a[3005 * 6005];
bool _tmp[3005 * 6005];
inline void get(int *f, int &cnt, int x, int y) {
  cnt = 0;
  if (x > 1) {
    f[++cnt] = (((x - 1) - 1) * ::c1 + (y));
  };
  if (x < r) {
    f[++cnt] = (((x + 1) - 1) * ::c1 + (y));
  };
  if (y > 1) {
    f[++cnt] = (((x)-1) * ::c1 + (y - 1));
  };
  if (y < c1) {
    f[++cnt] = (((x)-1) * ::c1 + (y + 1));
  };
  if (x > 1 && y > 1) {
    f[++cnt] = (((x - 1) - 1) * ::c1 + (y - 1));
  };
  if (x > 1 && y < c1) {
    f[++cnt] = (((x - 1) - 1) * ::c1 + (y + 1));
  };
  if (x < r && y > 1) {
    f[++cnt] = (((x + 1) - 1) * ::c1 + (y - 1));
  };
  if (x < r && y < c1) {
    f[++cnt] = (((x + 1) - 1) * ::c1 + (y + 1));
  };
};
int main() {
  read(r);
  read(c);
  read(n);
  c1 = c << 1;
  if (c == 1) {
    puts("0");
    return 0;
  };
  int ans = 0;
  while (n--) {
    int x, y;
    read(x);
    read(y);
    int f1[10], f2[10], c1, c2, fa1[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0},
                                fa2[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
    get(f1, c1, x, y);
    get(f2, c2, x, y + c);
    int i;
    for (i = 1; i <= c1; i++) {
      if (a[f1[i]]) {
        fa1[i] = getfa(f1[i]);
        _tmp[fa1[i]] = 1;
      };
    };
    for (i = 1; i <= c2; i++) {
      if (a[f2[i]]) {
        int t = getfa(f2[i]);
        if (_tmp[t]) break;
        fa2[i] = t;
      };
    };
    if (i > c2) {
      int p1 = (((x)-1) * ::c1 + (y)), p2 = (((x)-1) * ::c1 + (y + c));
      for (i = 1; i <= c1; i++) {
        fa[fa1[i]] = p1;
      };
      for (i = 1; i <= c2; i++) {
        fa[fa2[i]] = p2;
      };
      a[p1] = a[p2] = 1;
      ++ans;
    };
    for (i = 1; i <= c1; i++) {
      _tmp[fa1[i]] = 0;
    };
  };
  printf("%d\n", ans);
}
