#include <bits/stdc++.h>
using namespace std;
const int fy[9] = {0, 1, 1, 1, 0, -1, -1, -1, 0};
const int fx[9] = {1, 1, 0, -1, -1, -1, 0, 1, 1};
int Cps, Cp2s;
int bhs[3333][6666];
int fa[11111111];
int zhan[11111111];
int siz[11111111];
int Cp[111], Cp2[111];
int r, c, ans, blocks, c2;
int top(int x) {
  int t;
  for (t = 0; fa[x] != x; t++) {
    zhan[t] = x;
    x = fa[x];
  }
  while (t--) fa[zhan[t]] = x;
  return x;
}
void merge(int a, int b) {
  a = top(a);
  b = top(b);
  if (a == b) return;
  if (siz[b] > siz[a]) swap(a, b);
  fa[b] = a;
  siz[a] += siz[b];
}
void optt(int x, int y) {
  int i, j, gg;
  Cps = 0;
  for (i = 0; i < 8; i++)
    if (x + fx[i] >= 1 && x + fx[i] <= r) {
      gg = y + fy[i];
      if (gg < 1) gg = c2;
      gg = bhs[x + fx[i]][gg];
      if (!gg) continue;
      gg = top(gg);
      for (j = 0; j < Cps; j++)
        if (gg == Cp[j]) break;
      if (j == Cps) Cp[Cps++] = gg;
    }
  Cp2s = 0;
  for (i = 0; i < 8; i++)
    if (x + fx[i] >= 1 && x + fx[i] <= r) {
      gg = y + c + fy[i];
      if (gg > c2) gg = 1;
      gg = bhs[x + fx[i]][gg];
      if (!gg) continue;
      gg = top(gg);
      for (j = 0; j < Cp2s; j++)
        if (gg == Cp2[j]) break;
      if (j == Cp2s) Cp2[Cp2s++] = gg;
    }
  for (i = 0; i < Cps; i++)
    for (j = 0; j < Cp2s; j++)
      if (Cp[i] == Cp2[j]) return;
  ans++;
  bhs[x][y] = ++blocks;
  fa[blocks] = blocks;
  for (i = 0; i < Cps; i++) merge(blocks, Cp[i]);
  bhs[x][y + c] = ++blocks;
  fa[blocks] = blocks;
  for (i = 0; i < Cp2s; i++) merge(blocks, Cp2[i]);
}
int main() {
  int q, i, j;
  scanf("%d%d%d", &r, &c, &q);
  c2 = c << 1;
  if (c == 1) {
    printf("0\n");
    return 0;
  }
  ans = 0;
  blocks = 0;
  while (q--) {
    scanf("%d%d", &i, &j);
    optt(i, j);
  }
  printf("%d\n", ans);
  return 0;
}
