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>
int r, c, n, rc, ans = 0;
bool a[3005][3005];
int f[3005 * 3005 * 2];
int p[8][2], num;
int getanc(int x) { return f[x] == x ? x : f[x] = getanc(f[x]); }
inline int getp(const int &x, const int &y) { return (x - 1) * c + y; }
void work(int x, int y) {
  if (x < 1 || x > r) return;
  bool rev = false;
  if (y < 1)
    y = c, rev = true;
  else if (y > c)
    y = 1, rev = true;
  if (!a[x][y]) return;
  p[num][0] = getanc(getp(x, y) + (rev ? rc : 0));
  p[num][1] = getanc(getp(x, y) + (rev ? 0 : rc));
  num++;
}
bool check(int x, int y) {
  num = 0;
  work(x - 1, y - 1);
  work(x - 1, y);
  work(x - 1, y + 1);
  work(x, y - 1);
  work(x, y + 1);
  work(x + 1, y - 1);
  work(x + 1, y);
  work(x + 1, y + 1);
  for (int i = 0; i < num; i++)
    for (int j = 0; j < num; j++)
      if (p[i][0] == p[j][1]) return false;
  int now0 = getanc(getp(x, y));
  int now1 = getanc(getp(x, y) + rc);
  for (int i = 0; i < num; i++) {
    f[p[i][0]] = now0;
    f[p[i][1]] = now1;
  }
  a[x][y] = true;
  return true;
}
int main() {
  scanf("%d%d%d", &r, &c, &n);
  if (c == 1) {
    printf("0\n");
    return 0;
  }
  rc = r * c;
  memset(a, false, sizeof(a));
  for (int i = 1; i <= rc * 2; i++) f[i] = i;
  for (int i = 1; i <= n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (check(x, y)) ans++;
  }
  printf("%d\n", ans);
  return 0;
}
