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;
int R, C, N, x, y, Ans;
int Parent[3333 * 6666];
bool Land[3333][6666];
int Dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
int Dy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
int Find(int x) { return Parent[x] < 0 ? x : Parent[x] = Find(Parent[x]); }
void Union(int n1, int n2) {
  int r1 = Find(n1), r2 = Find(n2);
  if (r1 == r2) return;
  if (Parent[r1] < Parent[r2]) {
    Parent[r1] += Parent[r2];
    Parent[r2] = r1;
  } else {
    Parent[r2] += Parent[r1];
    Parent[r1] = r2;
  }
}
bool check(int x, int y) {
  for (int d1 = 0; d1 < 8; ++d1) {
    int newx1 = x + Dx[d1], newy1 = y + Dy[d1];
    if (newx1 < 1 || newx1 > R) continue;
    if (newy1 == 0) newy1 = 2 * C;
    if (newy1 > 2 * C) newy1 = 1;
    for (int d2 = 0; d2 < 8; ++d2) {
      int newx2 = x + Dx[d2], newy2 = y + C + Dy[d2];
      if (newx2 < 1 || newx2 > R) continue;
      if (newy2 == 0) newy2 = 2 * C;
      if (newy2 > 2 * C) newy2 = 1;
      if (Land[newx1][newy1] && Land[newx2][newy2] &&
          Find(newx1 * 6666 + newy1) == Find(newx2 * 6666 + newy2))
        return false;
    }
  }
  return true;
}
void add(int x, int y) {
  for (int d = 0; d < 8; ++d) {
    int newx = x + Dx[d], newy = y + Dy[d];
    if (newx < 1 || newx > R) continue;
    if (newy <= 0) newy += 2 * C;
    if (newy > 2 * C) newy -= 2 * C;
    if (Land[newx][newy]) Union(x * 6666 + y, newx * 6666 + newy);
  }
  Land[x][y] = true;
}
int main() {
  scanf("%d%d%d", &R, &C, &N);
  memset(Parent, -1, sizeof(Parent));
  while (N--) {
    scanf("%d%d", &x, &y);
    if (check(x, y)) {
      ++Ans;
      add(x, y);
      add(x, y + C);
    }
  }
  if (y == 1)
    puts("0");
  else
    printf("%d\n", Ans);
  return 0;
}
