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;
namespace io {
const int _SZIE = (1 << 21) + 1;
char ibuf[_SZIE], *iS, *iT, c, stk[46];
int tot;
template <class I>
inline void read(I &_x) {
  I fl = 1;
  for (c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, _SZIE, stdin),
                       (iS == iT ? EOF : *iS++))
                     : *iS++);
       c < '0' || c > '9';
       c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, _SZIE, stdin),
                       (iS == iT ? EOF : *iS++))
                     : *iS++))
    if (c == '-') fl = -1;
  for (_x = 0; c >= '0' && c <= '9';
       c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, _SZIE, stdin),
                       (iS == iT ? EOF : *iS++))
                     : *iS++))
    _x = _x * 10 + (c & 15);
  _x *= fl;
}
template <class I>
inline void prt(I _x, char ch = '\0') {
  tot = 0;
  if (_x < 0) putchar('-'), _x *= -1;
  do {
    stk[tot++] = _x % 10 | 48;
    _x /= 10;
  } while (_x);
  do {
    putchar(stk[--tot]);
  } while (tot);
  if (ch) putchar(ch);
}
}  // namespace io
using io::prt;
using io::read;
const int N = 3005;
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
int c, r, fa[N * N * 3], n;
bool de[N][2 * N];
inline int hash2(int _x, int _y) { return (_x - 1) * c * 2 + _y; }
int find(int _x) { return fa[_x] == _x ? _x : fa[_x] = find(fa[_x]); }
inline bool check(int _x, int _y) {
  for (int i = 0; i < 8; i++) {
    int xx = _x + dx[i], yy = _y + dy[i];
    if (yy == 0) yy = c * 2;
    if (yy == c * 2 + 1) yy = 1;
    if (xx > 0 && xx <= r && de[xx][yy]) {
      for (int j = 0; j < 8; j++) {
        int _xx = _x + dx[j], _yy = _y + dy[j] + c;
        if (_yy == 0) _yy = c * 2;
        if (_yy == c * 2 + 1) _yy = 1;
        if (_xx > 0 && _xx <= r && de[_xx][_yy]) {
          if (find(hash2(_xx, _yy)) == find(hash2(xx, yy))) return false;
        }
      }
    }
  }
  return true;
}
inline void solve() {
  int _x, _y, ans = 0;
  read(r), read(c), read(n);
  if (c == 1) {
    puts("0");
    return;
  }
  for (int i = 1; i <= r; i++) {
    for (int j = 1; j <= c * 2; j++) {
      fa[hash2(i, j)] = hash2(i, j);
      de[i][j] = 0;
    }
  }
  for (int i = 1; i <= n; i++) {
    read(_x);
    read(_y);
    if (check(_x, _y)) {
      for (int j = 0; j < 8; j++) {
        int _xx = _x + dx[j], _yy = _y + dy[j], _yy1 = _yy + c;
        if (_yy == 0) _yy = c * 2;
        if (_yy == c * 2 + 1) _yy = 1;
        if (_yy1 == 0) _yy1 = c * 2;
        if (_yy1 == c * 2 + 1) _yy1 = 1;
        if (de[_xx][_yy] && _xx > 0 && _xx <= r) {
          int u = find(hash2(_xx, _yy)), v = find(hash2(_x, _y));
          fa[u] = v;
        }
        if (de[_xx][_yy1] && _xx > 0 && _xx <= r) {
          int u = find(hash2(_xx, _yy1)), v = find(hash2(_x, _y + c));
          fa[u] = v;
        }
      }
      de[_x][_y] = true;
      de[_x][_y + c] = true;
      ans++;
    } else {
    }
  }
  prt(ans, '\n');
}
int main() {
  int T;
  T = 1;
  while (T--) {
    solve();
  }
  return 0;
}
