#include <bits/stdc++.h>
const int R = 3e3;
const int C = 6e3;
const int N = 3e5;
const int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[8] = {0, 1, 0, -1, -1, 1, 1, -1};
int r, c, n;
class DisjointSet {
 public:
  static const int NODE = R * C + 1;
  int fa_[NODE + 1];
  inline void init(int u) { fa_[u] = u; }
  int find(int u) { return fa_[u] == u ? u : fa_[u] = find(fa_[u]); }
  void merge(int u, int v) {
    u = find(u), v = find(v);
    fa_[u] = v;
  }
  bool connect(int u, int v) {
    u = find(u), v = find(v);
    return u == v;
  }
} s;
inline int id(int x, int y) { return (x - 1) * (c << 1) + y; }
bool filled[R + 1][C + 1];
inline bool valid(int &x, int &y) {
  if (y == 0) y = c << 1;
  if (y == (c << 1) + 1) y = 1;
  return x > 0 && x <= r && filled[x][y];
}
bool check(int x, int y) {
  int tx = x, ty = y + c;
  for (int i = 0; i < 8; ++i) {
    int nx = x + dx[i];
    int ny = y + dy[i];
    if (!valid(nx, ny)) continue;
    for (int j = 0; j < 8; ++j) {
      int ntx = tx + dx[j], nty = ty + dy[j];
      if (!valid(ntx, nty)) continue;
      if (s.connect(id(nx, ny), id(ntx, nty))) return false;
    }
  }
  return true;
}
void remove(int x, int y) {
  int tx = x, ty = y + c;
  for (int i = 0; i < 8; ++i) {
    int nx = x + dx[i];
    int ny = y + dy[i];
    int ntx = tx + dx[i];
    int nty = ty + dy[i];
    if (valid(nx, ny)) s.merge(id(x, y), id(nx, ny));
    if (valid(ntx, nty)) s.merge(id(tx, ty), id(ntx, nty));
  }
  filled[x][y] = filled[tx][ty] = true;
}
void work() {
  scanf("%d%d%d", &r, &c, &n);
  if (c == 1) return (void)(puts("0"));
  for (int i = 1; i <= r * c << 1; ++i) s.init(i);
  std::fill(filled[0], filled[0] + r * (c << 1) + 1, false);
  int ans = 0;
  while (n--) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (check(x, y)) remove(x, y), ++ans;
  }
  printf("%d\n", ans);
}
int main() {
  work();
  return 0;
}
