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;
bool a[3000 + 5][(3000 << 1) + 5], vis[(3000 + 5) * ((3000 << 1) + 5)];
int father[30000000 + 5], t, r, c, n, step[8][2];
int check(int x, int y) {
  if (x < 1 || x > r || y < 1 || y > (c << 1)) return 0;
  return a[x][y];
}
int getfather(int u) {
  return father[u] == u ? u : father[u] = getfather(father[u]);
}
void ui(int u, int v) {
  u = getfather(u), v = getfather(v);
  if (u == v) return;
  father[u] = v;
}
int main() {
  scanf("%d%d%d", &r, &c, &n);
  for (int i = 1; i <= ((r - 1) * (c << 1) + (c << 1)); i++) father[i] = i;
  int ans = 0;
  step[0][0] = -1, step[0][1] = -1;
  step[1][0] = -1, step[1][1] = 0;
  step[2][0] = -1, step[2][1] = 1;
  step[3][0] = 0, step[3][1] = -1;
  step[4][0] = 0, step[4][1] = 1;
  step[5][0] = 1, step[5][1] = -1;
  step[6][0] = 1, step[6][1] = 0;
  step[7][0] = 1, step[7][1] = 1;
  memset(a, 0, sizeof(a));
  while (n--) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (c == 1) continue;
    a[x][y] = a[x][y + c] = 1;
    for (int i = 0; i < 8; i++)
      if (check(x + step[i][0], y + step[i][1]))
        vis[getfather(((x + step[i][0] - 1) * (c << 1) + (y + step[i][1])))] =
            1;
    y += c;
    bool flag = 0;
    for (int i = 0; i < 8; i++)
      if (check(x + step[i][0], y + step[i][1]))
        if (vis[getfather(
                ((x + step[i][0] - 1) * (c << 1) + (y + step[i][1])))])
          flag = 1;
    y -= c;
    for (int i = 0; i < 8; i++)
      if (check(x + step[i][0], y + step[i][1]))
        vis[getfather(((x + step[i][0] - 1) * (c << 1) + (y + step[i][1])))] =
            0;
    if (flag) {
      a[x][y] = a[x][y + c] = 0;
      continue;
    }
    for (int i = 0; i < 8; i++)
      if (check(x + step[i][0], y + step[i][1]))
        vis[((x + step[i][0] - 1) * (c << 1) + (y + step[i][1]))] = 0,
                                                    ui(((x - 1) * (c << 1) +
                                                        (y)),
                                                       ((x + step[i][0] - 1) *
                                                            (c << 1) +
                                                        (y + step[i][1])));
    y += c;
    for (int i = 0; i < 8; i++)
      if (check(x + step[i][0], y + step[i][1]))
        ui(((x - 1) * (c << 1) + (y)),
           ((x + step[i][0] - 1) * (c << 1) + (y + step[i][1])));
    ans++;
  }
  printf("%d\n", ans);
  return 0;
}
