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>
namespace IO {
char cc;
int C;
template <class T>
void read(T &x) {
  x = 0;
  cc = getchar();
  C = 1;
  while (!('0' <= cc && cc <= '9')) {
    if (cc == '-') C = -1;
    cc = getchar();
  }
  while (('0' <= cc && cc <= '9')) {
    x = x * 10 + cc - 48;
    cc = getchar();
  }
  x *= C;
}
}  // namespace IO
using namespace IO;
using namespace std;
const int _x[8] = {-1, -1, -1, 0, 0, 1, 1, 1},
          _y[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
bool coordinate[3010][3010 << 1];
int fa[20000000];
int r, c, n, ans;
int getfa(const int &x) { return fa[x] == x ? x : fa[x] = getfa(fa[x]); }
inline void merge(int x, int y) {
  x = getfa(x);
  y = getfa(y);
  if (x != y) fa[x] = y;
}
inline int pt(const int &x, const int &y) { return ((x - 1) * (c << 1) + y); }
inline bool ok(int &x, int &y) {
  y -= y > (c << 1) ? (c << 1) : 0;
  y += (!y) ? (c << 1) : 0;
  return (x && x <= r && coordinate[x][y]);
}
inline void init() {
  for (register int i = 1; i <= (r * c) << 1; ++i) fa[i] = i;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  srand(time(0));
  cin >> r >> c >> n;
  if (c == 1) {
    puts("0");
    return 0;
  }
  init();
  register int a, b1, b2, x[3], y[3], _, __;
  register bool flag;
  for (register int k = 1; k <= n; ++k) {
    cin >> a >> b1;
    b2 = b1 + c;
    flag = false;
    for (register int i = 0; i <= 7; ++i) {
      x[0] = a + _x[i];
      y[0] = b1 + _y[i];
      if (!ok(x[0], y[0])) continue;
      _ = getfa(pt(x[0], y[0]));
      for (register int j = 0; j <= 7; ++j) {
        x[1] = a + _x[j];
        y[1] = b2 + _y[j];
        if (!ok(x[1], y[1])) continue;
        __ = getfa(pt(x[1], y[1]));
        flag = (_ == __);
        if (flag) break;
      }
      if (flag) break;
    }
    if (flag) continue;
    ++ans;
    coordinate[a][b1] = coordinate[a][b2] = 1;
    _ = pt(a, b1);
    __ = pt(a, b2);
    for (register int i = 0; i <= 7; ++i) {
      x[0] = a + _x[i];
      y[0] = b1 + _y[i];
      if (ok(x[0], y[0])) merge(_, pt(x[0], y[0]));
      x[1] = a + _x[i];
      y[1] = b2 + _y[i];
      if (ok(x[1], y[1])) merge(__, pt(x[1], y[1]));
    }
  }
  cout << ans;
  return 0;
}
