#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) + y; }
bool ok(int &u, int &v) {
  if (u > r || u < 1) return false;
  if (v < 1) v += 2 * c;
  if (v > 2 * c) v -= 2 * c;
  int sh = num(u, v);
  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[r1] = r2;
}
void connect(vector<int> &ls) {
  for (int i = 1; i < ls.size(); i++) {
    merge(ls[i], ls[0]);
  }
}
void solve(int x, int y) {
  cnt++;
  vector<int> ls, 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 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) return;
    ls2.push_back(r);
  }
  res++;
  int sh1 = num(x, y), sh2 = num(nx, ny);
  land[sh1] = land[sh2] = true;
  root[sh1] = root[sh2] = -1;
  connect(ls);
  connect(ls2);
}
int main() {
  int n;
  cin >> r >> c >> n;
  if (c == 1) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = (1), _b = (n); i <= _b; i++) {
    int u, v;
    cin >> u >> v;
    solve(u, v);
  }
  cout << res << endl;
  return 0;
}
