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 n, m, i, j, k, x, y, z, r, c;
int s[300010], t[300010], ans;
int a[3010][2 * 3010], id[3010][2 * 3010], f[2 * 3010], g[2 * 3010];
int cnt;
int dx[] = {0, 0, 0, 1, -1, -1, 1, -1, 1};
int dy[] = {0, 1, -1, 0, 0, -1, 1, 1, -1};
int ti, tj;
int fa[2 * 3010 * 3010], fb[2 * 3010 * 3010], pnt;
int getint() {
  int ret = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch >= '0' && ch <= '9') {
    ret = ret * 10 + ch - '0';
    ch = getchar();
  }
  return ret;
}
int find(int x, int *f) { return x == f[x] ? x : f[x] = find(f[x], f); }
void Turn(int tar, int *f, int fl) {
  int x = s[tar], y = t[tar], tx, ty, now;
  if (fl) {
    for (int i = 0; i <= 8; i++) {
      tx = x + dx[i], ty = y + dy[i];
      if (tx <= 0 || tx > r || ty <= 0 || ty > 2 * c) continue;
      now = id[tx][ty];
      while (f[now] != now) {
        ++pnt;
        fa[pnt] = now, fb[pnt] = f[now];
        now = f[now];
      }
      ++pnt;
      fa[pnt] = now, fb[pnt] = f[now];
    }
    for (int i = 0; i <= 8; i++) {
      tx = x + dx[i], ty = y + c + dy[i];
      if (tx <= 0 || tx > r || ty <= 0 || ty > 2 * c) continue;
      now = id[tx][ty];
      while (f[now] != now) {
        ++pnt;
        fa[pnt] = now, fb[pnt] = f[now];
        now = f[now];
      }
      ++pnt;
      fa[pnt] = now, fb[pnt] = f[now];
    }
  }
  for (int i = 1; i <= 8; i++) {
    tx = x + dx[i], ty = y + dy[i];
    if (tx <= 0 || tx > r || ty <= 0 || ty > 2 * c) continue;
    if (a[tx][ty] == 1) f[find(id[tx][ty], f)] = f[find(id[x][y], f)];
  }
  y += c;
  for (int i = 1; i <= 8; i++) {
    tx = x + dx[i], ty = y + dy[i];
    if (tx <= 0 || tx > r || ty <= 0 || ty > 2 * c) continue;
    if (a[tx][ty] == 1) f[find(id[tx][ty], f)] = f[find(id[x][y], f)];
  }
}
void Return() {
  for (int i = 1; i <= pnt; i++) g[fa[i]] = fb[i];
}
bool Try(int tar) {
  int x = s[tar], y = t[tar], lx, ly, rx, ry;
  bool fl = 0;
  for (int i = 1; i <= 8; i++)
    for (int j = 1; j <= 8; j++) {
      lx = x + dx[i], ly = y + dy[i];
      rx = x + dx[j], ry = y + c + dy[j];
      if (lx >= 1 && lx <= r && rx >= 1 && rx <= r) {
        if (ly < 1) ly = 2 * c;
        if (ly > 2 * c) ly = 1;
        if (ry < 1) ry = 2 * c;
        if (ry > 2 * c) ry = 1;
        if (lx == rx && ly == ry)
          if (a[lx][ly] == 1)
            return false;
          else
            continue;
        if (find(id[lx][ly], f) == find(id[rx][ry], f)) return false;
      }
    }
  pnt = 0;
  a[s[tar]][t[tar]] = a[s[tar]][t[tar] + c] = 1;
  Turn(tar, g, 1);
  for (int i = 1; i <= 8; i++)
    for (int j = 1; j <= 8; j++) {
      lx = x + dx[i], ly = y + dy[i];
      rx = x + dx[j], ry = y + c + dy[j];
      if (lx >= 1 && lx <= r && rx >= 1 && rx <= r) {
        if (ly < 1) ly = 2 * c;
        if (ly > 2 * c) ly = 1;
        if (ry < 1) ry = 2 * c;
        if (ry > 2 * c) ry = 1;
        if (lx == rx && ly == ry)
          if (a[lx][ly] == 1)
            return false;
          else
            continue;
        if (find(id[lx][ly], g) == find(id[rx][ry], g)) return false;
      }
    }
  return true;
}
int main() {
  r = getint(), c = getint(), n = getint();
  if (c == 1) {
    printf("0");
    return 0;
  }
  for (i = 1; i <= n; i++) s[i] = getint(), t[i] = getint();
  for (i = 1; i <= r; i++)
    for (j = 1; j <= 2 * c; j++) id[i][j] = ++cnt, f[cnt] = g[cnt] = cnt;
  for (i = 1; i <= n; i++)
    if (Try(i)) {
      a[s[i]][t[i]] = a[s[i]][t[i] + c] = 1;
      ans++;
      Turn(i, f, 0);
    } else {
      Return();
      a[s[i]][t[i]] = a[s[i]][t[i] + c] = 0;
    }
  printf("%d", ans);
  return 0;
}
