#include <bits/stdc++.h>
using namespace std;
int n, m, a[3010][6010], fa[18010000];
int dx[9] = {-1, -1, -1, 0, 0, 1, 1, 1}, dy[9] = {-1, 0, 1, -1, 1, -1, 0, 1};
inline int read() {
  int x = 0, f = 0;
  char ch = getchar();
  while (!isdigit(ch)) f = ch == '-', ch = getchar();
  while (isdigit(ch)) x = (x << 3) + (x << 1) + ch - 48, ch = getchar();
  return f ? -x : x;
}
inline int find(int x) { return fa[x] == x ? x : fa[x] = find(fa[x]); }
inline int calc(int x, int y) { return (x - 1) * m * 2 + y; }
int main() {
  int ans = 0;
  n = read(), m = read();
  int Q = read();
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= 2 * m; j++) fa[calc(i, j)] = calc(i, j);
  if (m == 1) {
    puts("0");
    return 0;
  }
  while (Q--) {
    int x = read(), y = read();
    int flag = 0;
    for (int i = 0; i < 8; i++) {
      int xx = x + dx[i], yy = y + dy[i];
      if (yy == 0) yy = 2 * m;
      if (xx < 1 || xx > n || !a[xx][yy]) continue;
      for (int j = 0; j < 8; j++) {
        int xxx = x + dx[j], yyy = y + m + dy[j];
        if (yyy > 2 * m) yyy = 1;
        if (xxx < 1 || xxx > n || !a[xxx][yyy]) continue;
        if (find(calc(xx, yy)) == find(calc(xxx, yyy))) {
          flag = 1;
          break;
        }
      }
    }
    if (flag) continue;
    a[x][y] = a[x][y + m] = 1;
    ans++;
    int fx1 = find(calc(x, y)), fx2 = find(calc(x, y + m));
    for (int i = 0; i < 8; i++) {
      int xx = x + dx[i], yy = y + dy[i];
      if (yy > m) {
        if (a[xx][yy]) fa[find(calc(xx, yy))] = fx1;
        if (a[xx][1]) fa[find(calc(xx, 1))] = fx2;
      } else if (yy < 1) {
        if (a[xx][yy + m]) fa[find(calc(xx, yy + m))] = fx2;
        if (a[xx][2 * m]) fa[find(calc(xx, 2 * m))] = fx1;
      } else {
        if (a[xx][yy]) fa[find(calc(xx, yy))] = fx1;
        if (a[xx][yy + m]) fa[find(calc(xx, yy + m))] = fx2;
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
