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 NMAX = 3005;
const int KMAX = 3005 * 3005 * 2 + 10;
int father[KMAX];
bitset<2 * NMAX> used[NMAX];
int find(int x) {
  int y, p;
  for (y = father[x]; y != father[y]; y = father[y])
    ;
  for (; x != y; x = p) {
    p = father[x];
    father[x] = y;
  }
  return y;
}
void unite(int x, int y) { father[find(x)] = find(y); }
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m, q;
  cin >> n >> m >> q;
  int k = n * m * 2;
  for (int i = 0; i < k; ++i) {
    father[i] = i;
  }
  const int dx[] = {-1, -1, 0, 1, 1, 1, 0, -1};
  const int dy[] = {0, 1, 1, 1, 0, -1, -1, -1};
  int ans = 0;
  while (q-- > 0) {
    int x, y;
    cin >> x >> y;
    if (m == 1) {
      continue;
    }
    x--;
    y--;
    vector<int> adj[2];
    for (int add = 0; add <= m; add += m) {
      vector<int> ccs;
      for (int d = 0; d < 8; ++d) {
        int nx = x + dx[d], ny = y + add + dy[d];
        if (nx < 0 || nx >= n || ny < 0 || ny >= 2 * m) {
          continue;
        }
        if (used[nx][ny]) {
          int c = find(nx * (2 * m) + ny);
          if (find(ccs.begin(), ccs.end(), c) == ccs.end()) {
            ccs.push_back(c);
          }
        }
      }
      adj[add > 0] = ccs;
    }
    bool ok = true;
    for (int c : adj[0]) {
      if (find(adj[1].begin(), adj[1].end(), c) != adj[1].end()) {
        ok = false;
        break;
      }
    }
    if (ok) {
      ans++;
      for (int add = 0; add <= m; add += m) {
        used[x][y + add] = true;
        for (int d = 0; d < 8; ++d) {
          int nx = x + dx[d], ny = y + add + dy[d];
          if (nx < 0 || nx >= n || ny < 0 || ny >= 2 * m) {
            continue;
          }
          if (used[nx][ny]) {
            int c = find(nx * (2 * m) + ny);
            unite((2 * m) * x + (y + add), c);
          }
        }
      }
    }
  }
  cout << ans << '\n';
}
