2 5 10
2 2
1 1
1 4
2 1
1 2
1 5
2 4
2 5
1 3
2 3
 2 2 2
1 1
2 2
 3 3 9
1 1
1 2
1 3
2 1
2 2
2 3
3 1
3 2
3 3
 7 5 35
5 3
3 5
1 1
2 5
6 4
7 2
5 1
3 4
6 5
7 3
4 1
2 2
4 2
2 4
4 3
3 3
6 1
1 2
4 5
1 3
2 1
5 5
7 5
7 1
6 2
1 4
1 5
3 2
4 4
5 2
2 3
6 3
7 4
5 4
3 1
 1 5 4
1 1
1 2
1 4
1 5
 1 1 1
1 1
 5 7 21
4 4
4 5
5 5
5 6
5 7
5 1
5 2
4 2
3 2
3 1
3 7
3 6
2 6
1 6
1 7
1 1
1 2
1 3
1 4
2 4
3 4
 2 1 1
1 1
 2 2 4
2 1
1 1
1 2
2 2
 3000 3000 1
2222 738
 5 7 35
1 2
2 3
5 1
5 7
4 4
5 3
3 1
2 6
4 5
2 7
4 1
2 1
2 2
1 7
5 6
3 6
4 6
1 6
1 1
3 3
3 4
4 2
2 5
5 5
3 5
2 4
1 5
1 3
4 3
5 4
1 4
3 7
4 7
3 2
5 2
 5 4 1
4 1
 3 4 12
2 3
3 2
2 2
2 1
1 2
3 1
1 4
1 3
3 3
2 4
3 4
1 1
 3 3 3
1 1
2 2
3 3

8
 1
 6
 26
 4
 0
 20
 0
 2
 1
 28
 1
 9
 3

#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 leftSide = maxR * maxC - 2;
int rightSide = maxR * maxC - 1;
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) || (y < 0) || (x >= r) || (y >= 2 * c)) return false;
  return true;
}
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);
    }
  }
  DSU[leftSide] = leftSide;
  DSU[rightSide] = rightSide;
  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++) {
    if ((valid(x + dx[i], y + dy[i])) && (land[x + dx[i]][y + dy[i]])) {
      connect(encode(x, y), encode(x + dx[i], y + dy[i]));
    }
  }
}
bool reachLeftSide, reachRightSide, reaches;
void setReached(int x, int y) {
  reaches = false;
  if (c == 1) reaches = true;
  set<int> firstReachable;
  for (int i = 0; i < 8; i++) {
    if ((valid(x + dx[i], y + dy[i])) && (land[x + dx[i]][y + dy[i]])) {
      int par = parent(encode(x + dx[i], y + dy[i]));
      firstReachable.insert(par);
    }
  }
  pair<int, int> mir = mirror(x, y);
  x = mir.first;
  y = mir.second;
  for (int i = 0; i < 8; i++) {
    if ((valid(x + dx[i], y + dy[i])) && (land[x + dx[i]][y + dy[i]])) {
      int par = parent(encode(x + dx[i], y + dy[i]));
      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;
}
