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 long long N = 3e3 + 7, M = 2e7 + 7;
bool vis[N][N * 2];
long long T, n, c, r;
long long dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
long long dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
long long fa[M];
long long ans = 0;
inline long long read() {
  long long n = 0;
  bool b = 0;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') b = 1;
    c = getchar();
  }
  while (c >= '0' && c <= '9')
    n = (n << 3) + (n << 1) + (c ^ 48), c = getchar();
  return b ? -n : n;
}
void init() {
  ans = 0;
  memset(vis, 0, sizeof(vis));
  memset(fa, 0, sizeof(fa));
}
inline long long get(long long x, long long y) { return (x - 1) * c * 2 + y; }
long long find(long long x) { return x == fa[x] ? x : fa[x] = find(fa[x]); }
bool check2(long long &x, long long &y) {
  if (y == 0)
    y = c * 2;
  else if (y == c * 2 + 1)
    y = 1;
  return (x > 0 && x <= r && vis[x][y]);
}
bool check1(long long x, long long y) {
  long long fx = x, fy = y + c;
  for (long long i = 0; i < 8; i++) {
    long long nx = x + dx[i], ny = y + dy[i];
    if (!check2(nx, ny)) continue;
    for (long long j = 0; j < 8; j++) {
      long long nfx = fx + dx[j], nfy = fy + dy[j];
      if (!check2(nfx, nfy)) continue;
      if (find(get(nx, ny)) == find(get(nfx, nfy))) {
        return 0;
      }
    }
  }
  return 1;
}
void merge(long long x, long long y) {
  long long fx = find(x), fy = find(y);
  fa[fx] = fy;
}
void del(long long x, long long y) {
  long long fx = x, fy = y + c;
  for (long long i = 0; i < 8; i++) {
    long long nx = x + dx[i], ny = y + dy[i];
    if (check2(nx, ny)) merge(get(x, y), get(nx, ny));
    long long nfx = fx + dx[i], nfy = fy + dy[i];
    if (check2(nfx, nfy)) merge(get(fx, fy), get(nfx, nfy));
  }
  vis[x][y] = 1;
  vis[fx][fy] = 1;
}
signed main() {
  init();
  r = read(), c = read(), n = read();
  for (long long i = 1; i <= r; i++)
    for (long long j = 1; j <= c * 2; j++) fa[get(i, j)] = get(i, j);
  long long ans = 0;
  while (n--) {
    long long x = read(), y = read();
    if (check1(x, y)) del(x, y), ans++;
  }
  if (c == 1) {
    puts("0");
    return 0;
  }
  printf("%d\n", ans);
  return 0;
}
