#include <bits/stdc++.h>
const int MAX = 18e6 + 5;
const int MAX_V = 1e3 + 5;
const int INF = 1e9 + 5;
const long long INF2 = 4e18 + 5;
const double M = 4e18;
using namespace std;
const int MOD = 1e9 + 7;
const double eps = 0.000000001;
int an;
int par[MAX];
int rankk[MAX];
void init(int n) {
  for (int i = 0; i < n; i++) {
    par[i] = i;
    rankk[i] = 0;
  }
}
int find(int x) {
  if (par[x] == x)
    return x;
  else
    return par[x] = find(par[x]);
}
void unite(int x, int y) {
  x = find(x);
  y = find(y);
  if (x == y) return;
  if (rankk[x] < rankk[y])
    par[x] = y;
  else {
    par[y] = x;
    if (rankk[x] == rankk[y]) rankk[x]++;
  }
}
bool same(int x, int y) { return find(x) == find(y); }
int n, m, q;
int a[MAX];
int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
bool vi[3005][6005];
int idx(int x, int y) { return (x - 1) * 2 * m + y; }
bool check(int x, int &y) { return x >= 1 && x <= n && y >= 1 && y <= 2 * m; }
int solve(int x, int y) {
  int x2 = x, y2 = y + m;
  for (int i = 0; i < 8; i++) {
    int x1 = x + dx[i], y1 = y + dy[i];
    if (y1 < 1)
      y1 += 2 * m;
    else if (y1 > 2 * m)
      y1 -= 2 * m;
    if (check(x1, y1) && vi[x1][y1]) {
      for (int j = 0; j < 8; j++) {
        int x3 = x2 + dx[j], y3 = y2 + dy[j];
        if (check(x3, y3) && vi[x3][y3])
          if (same(idx(x3, y3), idx(x1, y1))) return 0;
      }
    }
  }
  return 1;
}
int main() {
  scanf("%d%d%d", &n, &m, &q);
  if (m == 1) return 0 * printf("0\n");
  init(2 * n * m + 3);
  int Max = 2 * m;
  while (q--) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (solve(x, y)) {
      vi[x][y] = vi[x][y + m] = true;
      ++an;
      for (int i = 0; i < 8; i++) {
        int x1 = x + dx[i], y1 = y + dy[i];
        if (y1 <= 0)
          y1 += Max;
        else if (y1 > Max)
          y1 -= Max;
        if (check(x1, y1) && vi[x1][y1]) unite(idx(x, y), idx(x1, y1));
        y1 += m;
        if (y1 <= 0)
          y1 += Max;
        else if (y1 > Max)
          y1 -= Max;
        if (check(x1, y1) && vi[x1][y1]) unite(idx(x, y + m), idx(x1, y1));
      }
    }
  }
  printf("%d\n", an);
  return 0;
}
