#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;
}
