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>
const int N = 3009;
const int TOTAL = 2 * N * N;
const int d[][2] = {{-1, -1}, {-1, 0}, {-1, 1}, {0, -1},
                    {0, 1},   {1, -1}, {1, 0},  {1, 1}};
int r, c, n;
bool g[N][2 * N];
int fa[TOTAL];
int rk[TOTAL];
inline int get(int x, int y) { return (x - 1) * 2 * c + y; }
inline int find(int x) {
  int anc = x, y;
  while (anc != fa[anc]) anc = fa[anc];
  while (x != anc) y = fa[x], fa[x] = anc, x = y;
  return anc;
}
inline bool merge(int x, int y) {
  x = find(x), y = find(y);
  if (x == y)
    return false;
  else {
    if (rk[x] > rk[y]) std::swap(x, y);
    fa[x] = y, rk[y] = std::max(rk[y], rk[x] + 1);
    return true;
  }
}
bool valid(int &x, int &y) {
  if (x < 1 || x > r)
    return false;
  else {
    if (y < 1)
      y += 2 * c;
    else if (y > 2 * c)
      y -= 2 * c;
    return g[x][y];
  }
}
inline void init() {
  std::cin >> r >> c >> n;
  for (int i = 1; i <= 2 * r * c; ++i) fa[i] = i, rk[i] = 1;
}
inline void solve() {
  int ans = 0;
  if (c == 1) {
    puts("0");
    return;
  }
  for (int i = 1; i <= n; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    bool flag = true;
    for (int j = 0; j < 8 && flag; ++j) {
      int ax = x + d[j][0], ay = y + d[j][1];
      if (valid(ax, ay)) {
        int a = get(ax, ay);
        for (int k = 0; k < 8 && flag; ++k) {
          int bx = x + d[k][0], by = y + c + d[k][1];
          if (valid(bx, by)) {
            int b = get(bx, by);
            if (find(a) == find(b)) flag = false;
          }
        }
      }
    }
    if (flag) {
      g[x][y] = g[x][y + c] = true;
      int a = get(x, y), b = get(x, y + c);
      for (int j = 0; j < 8; ++j) {
        int nx = x + d[j][0], ny = y + d[j][1];
        if (valid(nx, ny)) merge(a, get(nx, ny));
        ny += c;
        if (valid(nx, ny)) merge(b, get(nx, ny));
      }
      ans++;
    }
  }
  std::cout << ans << std::endl;
}
int main() {
  init();
  solve();
  return 0;
}
