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;
#pragma comment(linker, "/STACK:1024000000,1024000000")
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= 1000000007;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % 1000000007;
    a = a * a % 1000000007;
  }
  return res;
}
long long gcd(long long x, long long y) {
  while (y) {
    long long t = x % y;
    x = y;
    y = t;
  }
  return x;
}
template <typename T>
inline bool chkmin(T &a, const T &b) {
  return a > b ? a = b, 1 : 0;
}
template <typename T>
inline bool chkmax(T &a, const T &b) {
  return a < b ? a = b, 1 : 0;
}
int dx[] = {0, -1, 0, 1, 1, -1, -1, 1};
int dy[] = {1, 0, -1, 0, 1, -1, 1, -1};
int fa[3010 * 3010 * 2], rk[3010 * 3010 * 2], g[3010][3010 * 2],
    id[3010][3010 * 2];
void init(int n) {
  for (int i = 0; i <= n; i++) fa[i] = i, rk[i] = 1;
}
int find(int x) {
  while (fa[x] != x) x = fa[x];
  return x;
}
stack<pair<int *, int> > s;
void Union(int x, int y) {
  x = find(x), y = find(y);
  if (x == y) return;
  if (rk[x] <= rk[y]) {
    s.push(make_pair(&fa[x], fa[x]));
    fa[x] = y;
    s.push(make_pair(&rk[y], rk[y]));
    rk[y] += rk[x];
  } else {
    s.push(make_pair(&fa[y], fa[y]));
    fa[y] = x;
    s.push(make_pair(&rk[x], rk[x]));
    rk[x] += rk[y];
  }
}
void back(int on) {
  while (!s.empty()) {
    if (on) *s.top().first = s.top().second;
    s.pop();
  }
}
void add(int x, int y, int r, int c) {
  for (int i = 0; i < 8; i++) {
    int nx = x + dx[i], ny = y + dy[i];
    if (ny < 1) ny += 2 * c;
    if (ny > 2 * c) ny -= 2 * c;
    if (nx >= 1 && nx <= r && g[nx][ny]) {
      Union(id[x][y], id[nx][ny]);
    }
  }
}
int main() {
  int r, c, n;
  scanf("%d %d %d", &r, &c, &n);
  for (int i = 1, t = 0; i <= r; i++)
    for (int j = 1; j <= 2 * c; j++) id[i][j] = t++;
  init(id[r][2 * c]);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    g[x][y] = g[x][y + c] = 1;
    add(x, y, r, c);
    add(x, y + c, r, c);
    if (find(id[x][y]) == find(id[x][y + c])) {
      back(1);
      g[x][y] = g[x][y + c] = 0;
    } else {
      back(0);
      ans++;
    }
  }
  printf("%d\n", ans);
  return 0;
}
