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;
long long rdtsc() {
  long long tmp;
  asm("rdtsc" : "=A"(tmp));
  return tmp;
}
inline int myrand() { return abs((rand() << 15) ^ rand()); }
inline int rnd(int x) { return myrand() % x; }
const int INF = (int)1e9 + 1;
const long double EPS = 1e-9;
int n, m, q;
inline bool ok(int x, int y) { return 0 <= x && x < n && 0 <= y && y < 2 * m; }
const int maxn = (int)3e3 + 10;
int used[maxn][2 * maxn];
const int maxv = maxn * maxn * 2;
int pr[maxv], w[maxv];
int get(int v) {
  if (pr[v] == v) {
    return v;
  }
  return pr[v] = get(pr[v]);
}
void myUnion(int a, int b) {
  a = get(a), b = get(b);
  if (a == b) {
    return;
  }
  if (w[a] == w[b]) {
    ++w[a];
  } else if (w[a] < w[b]) {
    swap(a, b);
  }
  pr[b] = a;
}
bool solve() {
  if (scanf("%d%d%d", &n, &m, &q) < 3) {
    return 0;
  }
  n += 2;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < 2 * m; ++j) {
      used[i][j] = 0;
    }
  }
  int cnt = n * 2 * m;
  for (int i = 0; i < cnt; ++i) {
    pr[i] = i, w[i] = 0;
  }
  int ans = 0;
  for (int i = 0; i < q; ++i) {
    int x, y;
    assert(scanf("%d%d", &x, &y) == 2);
    --x, --y;
    x += 1;
    bool fail = 0;
    for (int dx = -1; !fail && dx <= 1; ++dx) {
      for (int dy = -1; !fail && dy <= 1; ++dy) {
        int nx = x + dx, ny = y + dy;
        if (nx == x && ny == y + m) {
          fail = 1;
          break;
        }
        if (!ok(nx, ny) || !used[nx][ny]) {
          continue;
        }
        for (int dx1 = -1; !fail && dx1 <= 1; ++dx1) {
          for (int dy1 = -1; !fail && dy1 <= 1; ++dy1) {
            int nx1 = x + dx1, ny1 = y + m + dy1;
            if (!ok(nx1, ny1) || !used[nx1][ny1]) {
              continue;
            }
            if (get(nx * 2 * m + ny) == get(nx1 * 2 * m + ny1)) {
              fail = 1;
              break;
            }
          }
        }
      }
    }
    if (fail) {
      continue;
    }
    used[x][y] = used[x][y + m] = 1;
    ++ans;
    for (int co = 0; co < 2; ++co, y += m) {
      for (int dx = -1; dx <= 1; ++dx) {
        for (int dy = -1; dy <= 1; ++dy) {
          int nx = x + dx, ny = y + dy;
          if (!ok(nx, ny) || !used[nx][ny]) {
            continue;
          }
          myUnion(nx * 2 * m + ny, x * 2 * m + y);
        }
      }
    }
  }
  printf("%d\n", ans);
  return 1;
}
int main() {
  srand(rdtsc());
  while (1) {
    if (!solve()) {
      break;
    }
  }
  return 0;
}
