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 ztd {
using namespace std;
template <typename T>
inline T read(T &t) {
  t = 0;
  short f = 1;
  char ch = getchar();
  double d = 0.1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -f;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') t = t * 10 + ch - '0', ch = getchar();
  if (ch == '.') {
    ch = getchar();
    while (ch <= '9' && ch >= '0') t += d * (ch ^ 48), d *= 0.1, ch = getchar();
  }
  t *= f;
  return t;
}
}  // namespace ztd
using namespace ztd;
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int maxn = 18200007;
int r, c, n;
bool vis[3007][6007];
int fa[maxn];
int get(int x) { return ((fa[x] == x) ? x : fa[x] = get(fa[x])); }
inline void merge(int x, int y) {
  int fx = get(x), fy = get(y);
  fa[fx] = fy;
}
inline int tran(int x, int y) { return (x - 1) * c * 2 + y; }
inline bool in(int &x, int &y) {
  if (y == 0)
    y = c * 2;
  else if (y == c * 2 + 1)
    y = 1;
  return x >= 1 && x <= r && vis[x][y];
}
inline bool check(int x, int y) {
  for (register int i = 0; i < 8; i++) {
    int nx = x + dx[i], ny = y + dy[i];
    if (!in(nx, ny)) continue;
    for (register int j = 0; j < 8; j++) {
      int nx1 = x + dx[j], ny1 = y + c + dy[j];
      if (!in(nx1, ny1)) continue;
      if (get(tran(nx, ny)) == get(tran(nx1, ny1))) {
        return 0;
      }
    }
  }
  return 1;
}
inline void del(int x, int y) {
  for (register int i = 0; i < 8; i++) {
    int nx = x + dx[i], ny = y + dy[i];
    if (in(nx, ny)) merge(tran(x, y), tran(nx, ny));
    int nx1 = x + dx[i], ny1 = y + c + dy[i];
    if (in(nx1, ny1)) merge(tran(x, y + c), tran(nx1, ny1));
  }
  vis[x][y] = 1;
  vis[x][y + c] = 1;
}
inline void Main() {
  read(r);
  read(c);
  read(n);
  if (c == 1) {
    puts("0");
    return;
  }
  for (int i = 1; i <= r; ++i)
    for (int j = 2 * c; j; --j) vis[i][j] = 0;
  for (int i = tran(r, c * 2); i; --i) fa[i] = i;
  int xx, yy, ans = 0;
  for (int i = 1; i <= n; ++i) {
    read(xx);
    read(yy);
    if (check(xx, yy)) ++ans, del(xx, yy);
  }
  cout << ans << '\n';
  return;
}
signed main() {
  int T = 1;
  while (T--) Main();
  return 0;
}
