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 maxn = 3005;
int r, c;
int n;
bool mat[maxn][maxn * 2] = {0};
int fa[maxn * maxn * 2] = {0};
int walk[8][2] = {0};
int Ans = 0;
int Zip(const int &x, const int &y) { return (x - 1) * c * 2 + y; }
void Unzip(const int &a, int &x, int &y) {
  y = (a - 1) % (c * 2) + 1;
  x = (a - 1) / (c * 2);
}
void Init() {
  int wt = -1;
  scanf("%d%d%d", &r, &c, &n);
  for (int i = -1; i <= 1; ++i) {
    for (int j = -1; j <= 1; ++j) {
      if (i != 0 || j != 0) {
        ++wt;
        walk[wt][0] = i;
        walk[wt][1] = j;
      }
    }
  }
}
int Getfa(int p) {
  if (fa[p] == p) return p;
  return fa[p] = Getfa(fa[p]);
}
void Solve() {
  int x, y, s;
  int tx, ty;
  int f1[9] = {0}, f2[9] = {0};
  int fp1, fp2;
  int N = r * c * 2;
  for (int i = 1; i <= N; ++i) fa[i] = i;
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d", &x, &y);
    s = Zip(x, y);
    fp1 = 0, fp2 = 0;
    mat[x][y] = 1;
    mat[x][y + c] = 1;
    for (int j = 0; j < 8; ++j) {
      tx = x + walk[j][0];
      ty = y + walk[j][1];
      if (mat[tx][ty] == 1 && tx > 0 && ty > 0 && tx <= r && ty <= c * 2) {
        f1[++fp1] = Getfa(Zip(tx, ty));
      }
    }
    f1[++fp1] = Zip(x, y);
    y += c;
    for (int j = 0; j < 8; ++j) {
      tx = x + walk[j][0];
      ty = y + walk[j][1];
      if (mat[tx][ty] == 1 && tx > 0 && ty > 0 && tx <= r && ty <= c * 2) {
        f2[++fp2] = Getfa(Zip(tx, ty));
      }
    }
    f2[++fp2] = Zip(x, y);
    bool ok = 1;
    for (int j = 1; j <= fp1; ++j) {
      for (int k = 1; k <= fp2; ++k) {
        if (f1[j] == f2[k]) {
          ok = 0;
          break;
        }
      }
      if (ok == 0) break;
    }
    if (ok == 0) {
      mat[x][y] = 0;
      mat[x][y - c] = 0;
      continue;
    } else
      ++Ans;
    y -= c;
    mat[x][y] = 1;
    mat[x][y + c] = 1;
    int root;
    root = Zip(x, y);
    for (int j = 1; j <= fp1; ++j) fa[f1[j]] = root;
    root = Zip(x, y + c);
    for (int j = 1; j <= fp2; ++j) fa[f2[j]] = root;
  }
}
void Put() { printf("%d\n", Ans); }
int main() {
  Init();
  Solve();
  Put();
  return 0;
}
