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 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;
}
