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>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
int r, c, res;
int root[3005 * 6005];
bool land[3005 * 6005];
int dd[3005 * 6005];
int cnt = 0;
int dx[] = {-1, -1, -1, 0, 1, 1, 1, 0};
int dy[] = {-1, 0, 1, 1, 1, 0, -1, -1};
int num(int x, int y) { return (x - 1) * (c * 2 + 2) + y; }
void init() {
  for (int i = (1), _b = (r); i <= _b; i++) {
    int sh = num(i, 0);
    root[sh] = -1;
    land[sh] = true;
  }
  for (int i = (1), _b = (r); i <= _b; i++) {
    int sh = num(i, 2 * c + 1);
    root[sh] = -1;
    land[sh] = true;
  }
}
bool ok(int u, int v) {
  int sh = num(u, v);
  if (u > r || u < 1) return false;
  if (!land[sh]) return false;
  return true;
}
int get_root(int v) {
  if (root[v] < 0) return v;
  return root[v] = get_root(root[v]);
}
void merge(int r1, int r2) {
  r1 = get_root(r1);
  r2 = get_root(r2);
  if (r1 == r2) return;
  root[r2] = r1;
}
void connect(vector<int> &ls) {
  for (int i = 1; i < ls.size(); i++) {
    merge(ls[i], ls[0]);
  }
}
void solve(int x, int y, int step) {
  bool connected = false;
  int left_right = 0;
  cnt++;
  vector<int> ls;
  vector<int> ls2;
  ls.push_back(num(x, y));
  for (int i = 0, _n = (8); i < _n; i++) {
    int u = x + dx[i];
    int v = y + dy[i];
    if (!ok(u, v)) continue;
    int r = get_root(num(u, v));
    dd[r] = cnt;
    ls.push_back(r);
  }
  int left_right2 = 0;
  int nx = x, ny = y + c;
  ls2.push_back(num(nx, ny));
  for (int i = 0, _n = (8); i < _n; i++) {
    int u = nx + dx[i];
    int v = ny + dy[i];
    if (!ok(u, v)) continue;
    int r = get_root(num(u, v));
    if (dd[r] == cnt) {
      connected = true;
    }
    ls2.push_back(r);
  }
  if (connected) return;
  res++;
  int sh1 = num(x, y), sh2 = num(nx, ny);
  land[sh1] = true;
  land[sh2] = true;
  root[sh1] = root[sh2] = -1;
  connect(ls);
  connect(ls2);
}
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> r >> c >> n;
  if (c == 1) {
    cout << 0 << endl;
    return 0;
  }
  init();
  for (int i = (1), _b = (n); i <= _b; i++) {
    int u, v;
    cin >> u >> v;
    solve(u, v, i);
  }
  cout << res << endl;
  return 0;
}
