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;
bool debug = false;
int n, m, k;
long long ln, lk, lm;
int r, c, ans;
int f[3005 * 3005 * 2];
bool sk[3005 * 3005 * 2];
int ff(int x) { return x == f[x] ? x : f[x] = ff(f[x]); }
int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1}, dy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
int gg(int x, int y, int num) {
  if (num == -1 || num == 8) return (x - 1) * c * 2 + y;
  int tx = x + dx[num], ty = dy[num] + y;
  if (tx < 1 || tx > r) return -1;
  if (ty < 1) ty = 2 * c;
  if (ty > c + c) ty = 1;
  return (tx - 1) * c * 2 + ty;
}
void pp(int x = 0) {
  for (int(i) = 1; (i) <= (int)(r); (i)++) {
    for (int(j) = 1; (j) <= (int)(c + c); (j)++)
      printf("%02d ", x == 0 ? sk[gg(i, j, -1)] : ff(gg(i, j, -1)));
    puts("");
  }
  puts("");
}
void cal(int x, int y) {
  int id, id1;
  for (int(j) = 0; (j) < (int)(8); (j)++) {
    id = gg(x, y, j);
    if (id == -1 || !sk[id]) continue;
    for (int(k) = 0; (k) < (int)(8); (k)++) {
      id1 = gg(x, y + c, k);
      if (id1 == -1 || !sk[id1]) continue;
      int fa = ff(id), fb = ff(id1);
      if (fa == fb) return;
    }
  }
  ans++;
  id = gg(x, y, -1);
  id1 = gg(x, y + c, -1);
  sk[id] = 1;
  sk[id1] = 1;
  for (int(j) = 0; (j) < (int)(9); (j)++) {
    id = gg(x, y, j);
    if (id == -1 || !sk[id]) continue;
    for (int(k) = 0; (k) < (int)(9); (k)++)
      if (j != k) {
        id1 = gg(x, y, k);
        if (id1 == -1 || !sk[id1]) continue;
        f[ff(id)] = ff(id1);
      }
  }
  for (int(j) = 0; (j) < (int)(9); (j)++) {
    id = gg(x, y + c, j);
    if (id == -1 || !sk[id]) continue;
    for (int(k) = 0; (k) < (int)(9); (k)++)
      if (j != k) {
        id1 = gg(x, y + c, k);
        if (id1 == -1 || !sk[id1]) continue;
        f[ff(id)] = ff(id1);
      }
  }
}
int main() {
  scanf("%d%d%d", &r, &c, &n);
  if (c == 1) {
    puts("0");
    return 0;
  }
  for (int(i) = 0; (i) < (int)(3005 * 3005 * 2); (i)++) f[i] = i;
  int x, y;
  for (int(i) = 1; (i) <= (int)(n); (i)++) {
    scanf("%d%d", &x, &y);
    cal(x, y);
  }
  printf("%d\n", ans);
  return 0;
}
