#include <bits/stdc++.h>
using namespace std;
bool debug = false;
int n, m, k;
long long ln, lk, lm;
int r, c, ans;
int f[3005 * 3005 * 2];
bool sk[3005 * 3005 * 2];
int ff(int x) { return x == f[x] ? x : f[x] = ff(f[x]); }
int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1}, dy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
int gg(int x, int y, int num) {
  if (num == -1 || num == 8) return (x - 1) * c * 2 + y;
  int tx = x + dx[num], ty = dy[num] + y;
  if (tx < 1 || tx > r) return -1;
  if (ty < 1) ty = 2 * c;
  if (ty > c + c) ty = 1;
  return (tx - 1) * c * 2 + ty;
}
void pp(int x = 0) {
  for (int(i) = 1; (i) <= (int)(r); (i)++) {
    for (int(j) = 1; (j) <= (int)(c + c); (j)++)
      printf("%02d ", x == 0 ? sk[gg(i, j, -1)] : ff(gg(i, j, -1)));
    puts("");
  }
  puts("");
}
void cal(int x, int y) {
  int id, id1;
  for (int(j) = 0; (j) < (int)(8); (j)++) {
    id = gg(x, y, j);
    if (id == -1 || !sk[id]) continue;
    for (int(k) = 0; (k) < (int)(8); (k)++) {
      id1 = gg(x, y + c, k);
      if (id1 == -1 || !sk[id1]) continue;
      int fa = ff(id), fb = ff(id1);
      if (fa == fb) return;
    }
  }
  ans++;
  id = gg(x, y, -1);
  id1 = gg(x, y + c, -1);
  sk[id] = 1;
  sk[id1] = 1;
  for (int(j) = 0; (j) < (int)(9); (j)++) {
    id = gg(x, y, j);
    if (id == -1 || !sk[id]) continue;
    for (int(k) = 0; (k) < (int)(9); (k)++)
      if (j != k) {
        id1 = gg(x, y, k);
        if (id1 == -1 || !sk[id1]) continue;
        f[ff(id)] = ff(id1);
      }
  }
  for (int(j) = 0; (j) < (int)(9); (j)++) {
    id = gg(x, y + c, j);
    if (id == -1 || !sk[id]) continue;
    for (int(k) = 0; (k) < (int)(9); (k)++)
      if (j != k) {
        id1 = gg(x, y + c, k);
        if (id1 == -1 || !sk[id1]) continue;
        f[ff(id)] = ff(id1);
      }
  }
}
int main() {
  scanf("%d%d%d", &r, &c, &n);
  if (c == 1) {
    puts("0");
    return 0;
  }
  for (int(i) = 0; (i) < (int)(3005 * 3005 * 2); (i)++) f[i] = i;
  int x, y;
  for (int(i) = 1; (i) <= (int)(n); (i)++) {
    scanf("%d%d", &x, &y);
    cal(x, y);
  }
  printf("%d\n", ans);
  return 0;
}
