#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
using namespace std;
template <typename T>
void ckmax(T &a, T b) {
  if (a < b) a = b;
}
template <typename T>
void ckmin(T &a, T b) {
  if (a > b) a = b;
}
inline int read() {
  int x = 0, neg = 1;
  char op = getchar();
  while (!isdigit(op)) {
    if (op == '-') neg = -1;
    op = getchar();
  }
  while (isdigit(op)) {
    x = 10 * x + op - '0';
    op = getchar();
  }
  return neg * x;
}
inline void print(int x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x >= 10) print(x / 10);
  putchar(x % 10 + '0');
}
const int N = 2e7 + 5;
int r, c, n, f[N], ans = 0;
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
bool delt[3005][6005];
inline int id(int x, int y) { return (x - 1) * c * 2 + y; }
inline bool ok(int &x, int &y) {
  if (y == 0)
    y = c * 2;
  else if (y == c * 2 + 1)
    y = 1;
  return (x > 0 && x <= r && delt[x][y]);
}
inline int find(int x) { return x == f[x] ? x : f[x] = find(f[x]); }
inline bool chk(int x, int y) {
  int x1 = x, y1 = y + c;
  for (register int i = 0; i < 8; i++) {
    int nx = x + dx[i], ny = y + dy[i];
    if (!ok(nx, ny)) continue;
    for (register int j = 0; j < 8; j++) {
      int nx1 = x1 + dx[j], ny1 = y1 + dy[j];
      if (!ok(nx1, ny1)) continue;
      if (find(id(nx, ny)) == find(id(nx1, ny1))) {
        return 0;
      }
    }
  }
  return 1;
}
inline void merge(int a, int b) {
  int x = find(a), y = find(b);
  f[x] = y;
}
inline void del(int x, int y) {
  int x1 = x, y1 = y + c;
  for (register int i = 0; i < 8; i++) {
    int nx = x + dx[i], ny = y + dy[i];
    if (ok(nx, ny)) merge(id(x, y), id(nx, ny));
    int nx1 = x1 + dx[i], ny1 = y1 + dy[i];
    if (ok(nx1, ny1)) merge(id(x1, y1), id(nx1, ny1));
  }
  delt[x][y] = 1;
  delt[x1][y1] = 1;
}
int main() {
  r = read(), c = read(), n = read();
  if (c == 1) {
    printf("0");
    return 0;
  }
  for (register int i = 1; i <= r; i++)
    for (register int j = 1; j <= c * 2; j++) f[id(i, j)] = id(i, j);
  while (n--) {
    int x = read(), y = read();
    if (chk(x, y)) del(x, y), ans++;
  }
  printf("%d\n", ans);
  return 0;
}
