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 iinf = 0x3f3f3f3f;
const long long linf = 0x3f3f3f3f3f3f3f3f;
const int N = 3000, M = 6000, qN = 3e5;
int n, m, qn, ans, mat[N][M], te[qN << 1];
using vec = pair<int, int>;
vector<vec> to({make_pair((-1), (0)), make_pair((1), (0)), make_pair((0), (-1)),
                make_pair((0), (1)), make_pair((-1), (-1)), make_pair((1), (1)),
                make_pair((-1), (1)), make_pair((1), (-1))});
vec operator+(vec p, vec q) {
  return make_pair((p.first + q.first),
                   ((p.second + q.second + (m << 1)) % (m << 1)));
}
int find(int u) { return te[u] == u ? u : (te[u] = find(te[u])); }
const bool LOCAL = false;
void print(vec p) { cout << "(" << p.first << "," << p.second << ") "; }
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  cin >> n >> m >> qn;
  for (int i = (0), I = (n); i < I; i++)
    for (int j = (0), I = (m << 1); j < I; j++) mat[i][j] = -1;
  iota(te, te + qn * 2, 0);
  for (int i = (0), I = (qn); i < I; i++) {
    if (LOCAL) cout << "ok yet\n";
    vec p, q;
    cin >> p.first >> p.second, --p.first, --p.second,
        q = p + make_pair((0), (m));
    if (LOCAL) print(p), print(q), cout << '\n';
    vector<int> adjp, adjq;
    for (vec d : to) {
      vec tp = p + d, tq = q + d;
      if (tp.first < 0 || tp.first >= n) continue;
      if (~mat[tp.first][tp.second]) adjp.push_back(mat[tp.first][tp.second]);
      if (~mat[tq.first][tq.second]) adjq.push_back(mat[tq.first][tq.second]);
    }
    bool con = false;
    for (int pa : adjp)
      for (int qa : adjq)
        if (find(pa) == find(qa)) {
          con = true;
          break;
        }
    if (!con) {
      ans++;
      for (int pa : adjp) te[find(pa)] = i;
      for (int qa : adjq) te[find(qa)] = i + qn;
      mat[p.first][p.second] = i, mat[q.first][q.second] = i + qn;
    }
    if (LOCAL) cout << "ans=" << ans << '\n';
  }
  cout << ans << '\n';
  return 0;
}
