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 std::cin;
using std::cout;
using std::endl;
long long Factorial(long long i) { return i > 1 ? i * Factorial(i - 1) : 1; }
long long Combination(long long n, long long r) {
  if (n - r < r) r = n - r;
  long long ansn = 1, ansr = 1;
  for (long long i = n - r + 1; i <= n; ++i) ansn *= i;
  for (long long j = 1; j <= r; ++j) ansr *= j;
  return ansn / ansr;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
std::vector<int> Eratosthenes(const int len, int *vis) {
  memset(vis, 0, sizeof(int) * len);
  std::vector<int> prime;
  int m = (int)sqrt(len + 0.5);
  for (int i = (2); i <= (m); ++i)
    if (!vis[i])
      for (int j = i * i; j < len; j += i) vis[j] = 1;
  for (int i = (2); i < (len); ++i)
    if (!vis[i]) prime.push_back(i);
  return prime;
}
void phi_table(int n, int *phi) {
  for (int i = (2); i <= (n); ++i) phi[i] = 0;
  phi[1] = 1;
  for (int i = (2); i <= (n); ++i)
    if (!phi[i])
      for (int j = i; j <= n; j += i) {
        if (!phi[j]) phi[j] = j;
        phi[j] = phi[j] / i * (i - 1);
      }
}
const int maxn = 3000 + 10;
const int dx[] = {1, 1, 1, 0, -1, -1, -1, 0};
const int dy[] = {1, 0, -1, -1, -1, 0, 1, 1};
int r, c, n, ans;
int id[maxn][maxn * 2], g[maxn][maxn * 2], fa[maxn * maxn * 2],
    rk[maxn * maxn * 2];
typedef std::pair<int &, int> p;
std::stack<p> s;
void init(int len) {
  for (int i = (0); i < (len); ++i) fa[i] = i, rk[i] = 0;
}
int find(int x) {
  while (x != fa[x]) x = fa[x];
  return x;
}
void Union(int x, int y, int on) {
  x = find(x), y = find(y);
  if (x == y) return;
  if (rk[x] <= rk[y]) {
    if (on) s.push(p(fa[x], fa[x]));
    fa[x] = y;
    if (rk[x] == rk[y]) {
      if (on) s.push(p(rk[y], rk[y]));
      rk[y]++;
    }
  } else {
    if (on) s.push(p(fa[y], fa[y]));
    fa[y] = x;
  }
}
void rollback(int on) {
  while (!s.empty()) {
    if (on) s.top().first = s.top().second;
    s.pop();
  }
}
void Add(int x, int y, int on) {
  for (int i = (0); i < (8); ++i) {
    int tx = x + dx[i], ty = y + dy[i];
    if (ty < 1) ty += 2 * c;
    if (ty > 2 * c) ty -= 2 * c;
    if (tx >= 1 && tx <= r && g[tx][ty]) Union(id[x][y], id[tx][ty], on);
  }
}
int main() {
  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(r * c * 2);
  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, 1);
    Add(x, y + c, 1);
    if (find(id[x][y]) == find(id[x][y + c])) {
      rollback(1);
      g[x][y] = g[x][y + c] = 0;
    } else {
      rollback(0);
      ++ans;
    }
  }
  cout << ans << endl;
  return 0;
}
