#include <bits/stdc++.h>
using namespace std;
const int mval = 3000;
int n, m, q;
int on[mval][mval];
int px[mval][mval];
int py[mval][mval];
int pd[mval][mval];
int mt[mval][mval];
void upd(int x, int y) {
  if (x != px[x][y] || y != py[x][y]) {
    int ppx = px[x][y];
    int ppy = py[x][y];
    upd(ppx, ppy);
    pd[x][y] += pd[ppx][ppy];
    px[x][y] = px[ppx][ppy];
    py[x][y] = py[ppx][ppy];
  }
}
int main() {
  scanf("%d %d %d", &n, &m, &q);
  for (int x = 0; x < n; x++)
    for (int y = 0; y < m; y++) {
      on[x][y] = 0;
      px[x][y] = x;
      py[x][y] = y;
      pd[x][y] = 0;
      mt[x][y] = -2;
    }
  if (m == 1) {
    for (int qq = 0; qq < q; qq++) scanf("%*d %*d");
    printf("0\n");
    return 0;
  }
  int ans = 0;
  for (int qq = 0; qq < q; qq++) {
    int x, y;
    scanf("%d %d", &x, &y);
    x--;
    y--;
    int d = 0;
    int npx = x, npy = y;
    mt[x][y] = 0;
    bool ok = true;
    for (int dx = -1; ok && dx <= 1; dx++)
      for (int dy = -1; ok && dy <= 1; dy++) {
        int nx = x + dx;
        int ny = y + dy;
        if (0 > nx || nx >= n) continue;
        if (0 > ny) ny += m;
        if (ny >= m) ny -= m;
        if (on[nx][ny] == 0) continue;
        upd(nx, ny);
        int nnx = px[nx][ny];
        int nny = py[nx][ny];
        int nd = pd[nx][ny] + dy;
        if (mt[nnx][nny] == -2) {
          mt[nnx][nny] = nd;
          if (d < nd) {
            d = nd;
            npx = nnx;
            npy = nny;
          }
        } else if (mt[nnx][nny] != nd)
          ok = false;
      }
    if (ok) {
      ans++;
      on[x][y] = 1;
    }
    for (int dx = -1; dx <= 1; dx++)
      for (int dy = -1; dy <= 1; dy++) {
        int nx = x + dx;
        int ny = y + dy;
        if (0 > nx || nx >= n) continue;
        if (0 > ny) ny += m;
        if (ny >= m) ny -= m;
        if (on[nx][ny] == 0) continue;
        upd(nx, ny);
        int nnx = px[nx][ny];
        int nny = py[nx][ny];
        if (ok) {
          if (nnx != npx || nny != npy) {
            px[nnx][nny] = npx;
            py[nnx][nny] = npy;
            pd[nnx][nny] = d - mt[nnx][nny];
          }
        }
        mt[nnx][nny] = -2;
      }
  }
  printf("%d\n", ans);
  return 0;
}
