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;
const int maxn = 3123;
int arr[maxn * maxn];
bool side[maxn * maxn];
int fnd(int x) {
  if (arr[x] == x) return x;
  int fa = arr[x];
  arr[x] = fnd(fa);
  side[x] ^= side[fa];
  return arr[x];
}
void join(int x, int y, bool sam) {
  int fx = x, fy = y;
  x = fnd(x), y = fnd(y);
  sam ^= side[x];
  sam ^= side[y];
  if (x == y) return;
  arr[x] = y;
  side[x] = sam;
}
bool check(int x, int y, int sam) {
  int fx = x, fy = y;
  x = fnd(x), y = fnd(y);
  sam ^= side[x];
  sam ^= side[y];
  if (x != y) return true;
  return sam == 0;
}
int id[maxn][maxn];
bool use[maxn][maxn];
int r, c;
int idlist[9];
bool idsa[9];
const int dx[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
const int dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
bool jud(int x, int y) {
  int len = 0;
  for (int d = 0; d < 8; d++) {
    int nx = x + dx[d];
    int ny = ((y - 1) + dy[d] + c) % c + 1;
    if (use[nx][ny]) {
      idlist[len] = id[nx][ny];
      idsa[len++] = (y == 1 && dy[d] == -1) || (y == c && dy[d] == 1);
    }
  }
  for (int i = 0; i < len; i++) {
    for (int j = i + 1; j < len; j++) {
      if (check(idlist[i], idlist[j], idsa[i] ^ idsa[j]) == false) return false;
    }
  }
  for (int i = 0; i < len; i++) {
    join(id[x][y], idlist[i], idsa[i]);
  }
  use[x][y] = true;
  return true;
}
int x[312345], y[312345];
int cal(int n) {
  if (c == 1) return 0;
  int ret = 0;
  for (int i = 0; i < n; i++) {
    ret += jud(x[i], y[i]);
  }
  return ret;
}
int main() {
  int n;
  scanf("%d %d %d", &r, &c, &n);
  for (int i = 0; i <= r * c + 1; i++) arr[i] = i, side[i] = 0;
  int len = 1;
  for (int i = 1; i <= r; i++) {
    for (int j = 1; j <= c; j++) {
      id[i][j] = len++;
    }
  }
  memset(use, 0, sizeof(use));
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &x[i], &y[i]);
  }
  printf("%d\n", cal(n));
  return 0;
}
