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;
int R, V, C, cnt, Q, ans = 0, n;
int father[300010], rank1[300010];
int id[1005][2005];
int root(int x) {
  if (father[x] != x) father[x] = root(father[x]);
  return father[x];
}
int connect(int x, int y) {
  int a = root(x);
  int b = root(y);
  if (a != b)
    if (rank1[x] >= rank1[y]) {
      rank1[x] += y;
      father[b] = a;
    } else {
      rank1[y] += rank1[x];
      father[a] = b;
    }
}
vector<int> neighbour(int r, int c) {
  vector<int> v;
  for (int i = -1; i <= 1; i++)
    for (int j = -1; j <= 1; j++) {
      if (id[r + i][c + j] != -1 && r + i >= 1 && r + i <= R && c + j >= 1 &&
          c + j <= (c + j + 2 * C) % (2 * C))
        v.push_back(id[r + i][c + j]);
    }
  return v;
}
void add(int r, int c) {
  rank1[V] = 1;
  father[V] = V;
  id[r][c] = V;
  V++;
  vector<int> v = neighbour(r, c);
  for (int i = 0; i < v.size(); i++) connect(id[r][c], v[i]);
}
bool can_add(int r, int c) {
  vector<int> v1 = neighbour(r, c);
  vector<int> v2 = neighbour(r, c + C);
  for (int i = 0; i < v1.size(); i++)
    for (int j = 0; j < v2.size(); j++)
      if (root(v1[i]) == root(v2[j])) return false;
  return true;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> R >> C >> n;
  memset(id, -1, sizeof(id));
  if (C == 1) {
    cout << "0" << endl;
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    int r, c;
    cin >> r >> c;
    if (can_add(r, c)) {
      add(r, c);
      add(r, c + C);
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
