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 MaxN = 3000;
const int MaxM = 3000;
const int MaxNL = MaxN * MaxM * 2;
int n, m, l, q;
int nl;
bool a[MaxN][MaxM];
int ufs[MaxNL];
int ufs_find(int v) {
  int r = v;
  while (ufs[r] != r) r = ufs[r];
  for (int u = v, p = ufs[u]; u != r; u = p, p = ufs[u]) ufs[u] = r;
  return r;
}
int main() {
  cin >> n >> m >> q;
  l = m * 2;
  nl = n * l;
  for (int v = 0; v < nl; v++) ufs[v] = v;
  int res = 0;
  while (q--) {
    int x, y;
    scanf("%d %d", &x, &y);
    x--, y--;
    if (m == 1) continue;
    bool ok = true;
    for (int dx = -1; dx <= 1; dx++)
      for (int dy = -1; dy <= 1; dy++)
        if (0 <= x + dx && x + dx < n)
          for (int ex = dx; ex <= 1; ex++)
            for (int ey = ex == dx ? dy + 1 : -1; ey <= 1; ey++)
              if (0 <= x + ex && x + ex < n) {
                int ux = x + dx, uy = (y + dy + l) % l;
                int wx = x + ex, wy = (y + ey + m) % l;
                if (a[ux][uy % m] && a[wx][wy % m] &&
                    ufs_find(ux * l + uy) == ufs_find(wx * l + wy))
                  ok = false;
              }
    if (!ok) continue;
    res++;
    for (int dx = -1; dx <= 1; dx++)
      for (int dy = -1; dy <= 1; dy++)
        if (0 <= x + dx && x + dx < n) {
          int ux = x + dx, uy = (y + dy + l) % l;
          if (a[ux][uy % m]) ufs[ufs_find(ux * l + uy)] = ufs_find(x * l + y);
        }
    for (int dx = -1; dx <= 1; dx++)
      for (int dy = -1; dy <= 1; dy++)
        if (0 <= x + dx && x + dx < n) {
          int ux = x + dx, uy = (y + dy + m) % l;
          if (a[ux][uy % m])
            ufs[ufs_find(ux * l + uy)] = ufs_find(x * l + m + y);
        }
    a[x][y] = true;
  }
  cout << res << endl;
  return 0;
}
