#include <bits/stdc++.h>
using namespace std;
const int maxR = 3002;
const int maxC = 6002;
bool land[maxR][2 * maxC];
int DSU[maxR * maxC];
int r, c;
int dx[8] = {1, 1, 1, 0, 0, -1, -1, -1};
int dy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
int encode(int x, int y) { return 2 * c * x + y; }
int encode(pair<int, int> a) { return 2 * c * a.first + a.second; }
bool valid(int x, int y) {
  if ((x < 0) || (x >= r)) return false;
  return true;
}
pair<int, int> fixPair(int x, int y) { return {x, (y + 2 * c) % (2 * c)}; }
pair<int, int> mirror(int x, int y) { return {x, (c + y) % (2 * c)}; }
int parent(int id) {
  if (id == DSU[id]) return id;
  return DSU[id] = parent(DSU[id]);
}
bool connect(int i, int j) {
  i = parent(i);
  j = parent(j);
  if (i != j) {
    DSU[i] = j;
    return true;
  }
  return false;
}
void initDSU(int r, int c) {
  for (int i = 0; i < r; i++) {
    for (int j = 0; j < 2 * c; j++) {
      DSU[encode(i, j)] = encode(i, j);
    }
  }
  for (int i = 0; i < r; i++) {
    for (int j = 0; j < 2 * c; j++) {
      land[i][j] = false;
    }
  }
}
void setCell(pair<int, int> coord) {
  int x = coord.first;
  int y = coord.second;
  land[x][y] = true;
  for (int i = 0; i < 8; i++) {
    pair<int, int> validPair = fixPair(x + dx[i], y + dy[i]);
    if ((valid(x + dx[i], y + dy[i])) &&
        (land[validPair.first][validPair.second])) {
      connect(encode(x, y), encode(validPair.first, validPair.second));
    }
  }
}
bool reaches;
void setReached(int x, int y) {
  reaches = false;
  if (c == 1) reaches = true;
  set<int> firstReachable;
  for (int i = 0; i < 8; i++) {
    pair<int, int> validPair = fixPair(x + dx[i], y + dy[i]);
    if ((valid(x + dx[i], y + dy[i])) &&
        (land[validPair.first][validPair.second])) {
      int par = parent(encode(validPair));
      firstReachable.insert(par);
    }
  }
  pair<int, int> mir = mirror(x, y);
  x = mir.first;
  y = mir.second;
  for (int i = 0; i < 8; i++) {
    pair<int, int> validPair = fixPair(x + dx[i], y + dy[i]);
    if ((valid(x + dx[i], y + dy[i])) &&
        (land[validPair.first][validPair.second])) {
      int par = parent(encode(validPair));
      if (firstReachable.find(par) != firstReachable.end()) reaches = true;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> r >> c >> n;
  initDSU(r, c);
  int ats = 0;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    setReached(x, y);
    if (!reaches) {
      ats++;
      pair<int, int> mir = mirror(x, y);
      setCell({x, y});
      setCell(mir);
    }
  }
  cout << ats;
  return 0;
}
