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 maxn = 3010;
long long n, m, k, tot, x, y, ans;
long long fa[maxn * (maxn << 1)], fail[maxn][maxn << 1], id[maxn][maxn << 1];
long long dx[8] = {-1, -1, 1, 1, 0, 0, 1, -1},
          dy[8] = {-1, 1, -1, 1, 1, -1, 0, 0};
inline long long read() {
  char c = getchar();
  long long f(1), x(0);
  for (; !isdigit(c); c = getchar()) (c == '-') && (f = -1);
  for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
  return f * x;
}
long long find(long long x) { return x == fa[x] ? x : fa[x] = find(fa[x]); }
inline bool chk(long long &x, long long &y) {
  if (y == 0) y = m + m;
  if (y == m + m + 1) y = 1;
  return (x > 0 && x <= n && fail[x][y]);
}
inline void merge(long long x, long long y) {
  long long f1 = find(x), f2 = find(y);
  fa[f1] = f2;
}
inline bool check(long long x, long long y) {
  long long x_ = x, y_ = y + m;
  for (register long long i = 0; i < 8; ++i) {
    long long xx = x + dx[i], yy = y + dy[i];
    if (!chk(xx, yy)) continue;
    for (register long long j = 0; j < 8; ++j) {
      long long xx_ = x_ + dx[j], yy_ = y_ + dy[j];
      if (!chk(xx_, yy_)) continue;
      if (find(id[xx][yy]) == find(id[xx_][yy_])) return false;
    }
  }
  x_ = x, y_ = y + m;
  for (register long long i = 0; i < 8; ++i) {
    long long xx = x + dx[i], yy = y + dy[i];
    if (chk(xx, yy)) merge(id[xx][yy], id[x][y]);
    long long xx_ = x_ + dx[i], yy_ = y_ + dy[i];
    if (chk(xx_, yy_)) merge(id[xx_][yy_], id[x_][y_]);
  }
  fail[x][y] = fail[x_][y_] = true;
  return true;
}
int main(void) {
  n = read(), m = read(), k = read();
  for (register long long i = 1; i <= n; ++i)
    for (register long long j = 1; j <= (m << 1); ++j)
      id[i][j] = ++tot, fa[tot] = tot;
  while (k--) {
    x = read(), y = read();
    if (check(x, y)) ans++;
  }
  printf("%lld\n", ans);
  return 0;
}
