#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;
}
