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 INF = 0x3f3f3f3f;
const long long INFF = 0x3f3f3f3f3f3f3f3fll;
const long long MOD = 1e9 + 7;
const long long maxn = 3000 + 7;
const double eps = 0.00000001;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
template <typename T>
inline T abs(T a) {
  return a > 0 ? a : -a;
}
template <typename T>
inline T powMM(T a, T b) {
  T ret = 1;
  for (; b; b >>= 1ll, a = a * a % MOD) ret = 1ll * ret * a % MOD;
  return ret;
}
int n, m, T;
int i, j, k;
int fa[maxn * maxn * 2];
int a[maxn][maxn * 2];
int q[maxn * maxn * 2], qf[maxn * maxn * 2];
int tot, ans;
int getid(int x, int y) { return (x - 1) * m * 2 + y; }
int getfather(int x) {
  if (fa[x] == x) return x;
  q[tot] = x;
  qf[tot++] = fa[x];
  return fa[x] = getfather(fa[x]);
}
void change(int x, int y) {
  int xx, yy, i, j;
  for (i = -1; i <= 1; i++)
    for (j = -1; j <= 1; j++) {
      int xx = x + i, yy = y + j;
      if (xx == x && yy == y) continue;
      if (yy == 0) yy = m * 2;
      if (yy == 2 * m + 1) yy = 1;
      if (xx > 0 && xx <= n && a[xx][yy]) {
        int u = getfather(getid(xx, yy)), v = getfather(getid(x, y));
        q[tot] = v;
        qf[tot++] = fa[v];
        fa[v] = u;
      }
    }
}
int main() {
  scanf("%d%d%d", &n, &m, &T);
  for (i = 1; i <= n * m * 2; i++) fa[i] = i;
  while (T--) {
    int x, y;
    scanf("%d%d", &x, &y);
    tot = 0;
    a[x][y] = a[x][y + m] = 1;
    change(x, y);
    change(x, y + m);
    if (getfather(getid(x, y)) == getfather(getid(x, y + m))) {
      a[x][y] = a[x][y + m] = 0;
      while (tot--) {
        fa[q[tot]] = qf[tot];
      }
    } else
      ans++;
  }
  printf("%d", ans);
}
