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;
struct timer {
  time_t start;
  timer() { start = clock(); }
  ~timer() {
    cerr << 1. * (clock() - start) / CLOCKS_PER_SEC << " secs" << endl;
  }
};
int par_uf[19000000], rank_uf[19000000];
void init(int n) {
  for (int i = 0; i < n; i++) {
    par_uf[i] = i;
    rank_uf[i] = 0;
  }
}
int find(int x) {
  if (par_uf[x] == x)
    return x;
  else
    return par_uf[x] = find(par_uf[x]);
}
void unite(int x, int y) {
  x = find(x);
  y = find(y);
  if (x == y) return;
  if (rank_uf[x] < rank_uf[y])
    par_uf[x] = y;
  else {
    par_uf[y] = x;
    if (rank_uf[x] == rank_uf[y]) rank_uf[x]++;
  }
}
bool same(int x, int y) { return find(x) == find(y); }
int r, c, C, n;
int dy[] = {0, 1, 1, 1, 0, -1, -1, -1};
int dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
bool m[3010][6010];
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cin >> r >> c >> n;
  if (c == 1) {
    cout << 0;
    return 0;
  }
  r += 2;
  C = 2 * c;
  init(r * C);
  int ans = 0;
  for (int ii = 0; ii < (n); ii++) {
    int y1, x1, y2, x2;
    cin >> y1 >> x1;
    x1--;
    y2 = y1, x2 = x1 + c;
    int ok = 1;
    for (int d1 = 0; d1 < (8); d1++)
      for (int d2 = 0; d2 < (8); d2++) {
        int ny1 = y1 + dy[d1], nx1 = (x1 + dx[d1] + C) % C;
        int ny2 = y2 + dy[d2], nx2 = (x2 + dx[d2] + C) % C;
        if (m[ny1][nx1] && m[ny2][nx2] &&
            same(((ny1)*C + (nx1)), ((ny2)*C + (nx2)))) {
          ok = 0;
          break;
        }
      }
    if (ok) {
      ans++;
      m[y1][x1] = m[y2][x2] = 1;
      for (int d = 0; d < (8); d++) {
        int ny1 = y1 + dy[d], nx1 = (x1 + dx[d] + C) % C;
        int ny2 = y2 + dy[d], nx2 = (x2 + dx[d] + C) % C;
        if (m[ny1][nx1]) {
          unite(((y1)*C + (x1)), ((ny1)*C + (nx1)));
        }
        if (m[ny2][nx2]) {
          unite(((y2)*C + (x2)), ((ny2)*C + (nx2)));
        }
      }
    }
  }
  cout << ans;
}
