#include <bits/stdc++.h>
using namespace std;
int n, m, T, tot, f[3005 * 3005 * 2], l1[3005 * 3005], l2[3005 * 3005];
int fx[2][10], del[3005][3005 * 2];
int Gf(int x) {
  l1[++tot] = x, l2[tot] = f[x];
  if (f[x] == x) return x;
  return f[x] = Gf(f[x]);
}
int C(int x, int y) { return (x - 1) * (m * 2) + y; }
void Merge(int x, int y) {
  int fx = Gf(x), fy = Gf(y);
  l1[++tot] = x, l2[tot] = fx;
  f[fx] = fy;
}
void Link(int x, int y) {
  int k = C(x, y);
  for (int i = 1; i <= 8; i++) {
    int nx = x + fx[0][i], ny = y + fx[1][i];
    if (ny == 0) ny = m + m;
    if (ny > m + m) ny = 1;
    if (nx == 0 || nx > n) continue;
    if (del[nx][ny]) Merge(k, C(nx, ny));
  }
}
int main() {
  fx[0][1] = fx[0][2] = fx[0][3] = -1, fx[0][4] = fx[0][5] = 0,
  fx[0][6] = fx[0][7] = fx[0][8] = 1;
  fx[1][1] = fx[1][4] = fx[1][6] = -1, fx[1][2] = fx[1][7] = 0,
  fx[1][3] = fx[1][5] = fx[1][8] = 1;
  scanf("%d%d%d", &n, &m, &T);
  int ans = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m + m; j++) f[C(i, j)] = C(i, j);
  for (int i = 1; i <= T; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    tot = 0;
    del[x][y] = del[x][y + m] = 1;
    Link(x, y), Link(x, y + m);
    if (Gf(C(x, y)) == Gf(C(x, y + m))) {
      del[x][y] = del[x][y + m] = 0;
      for (int j = tot; j; j--) f[l1[j]] = l2[j];
    } else
      ans++;
  }
  cout << ans << endl;
  return 0;
}
