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;
int n, m, T, tot, f[3005 * 3005 * 2], l1[3005 * 3005], l2[3005 * 3005];
int fx[2][10], del[3005][3005 * 2];
int Gf(int x) {
  l1[++tot] = x, l2[tot] = f[x];
  if (f[x] == x) return x;
  return f[x] = Gf(f[x]);
}
int C(int x, int y) { return (x - 1) * (m * 2) + y; }
void Merge(int x, int y) {
  int fx = Gf(x), fy = Gf(y);
  l1[++tot] = x, l2[tot] = fx;
  f[fx] = fy;
}
void Link(int x, int y) {
  int k = C(x, y);
  for (int i = 1; i <= 8; i++) {
    int nx = x + fx[0][i], ny = y + fx[1][i];
    if (ny == 0) ny = m + m;
    if (ny > m + m) ny = 1;
    if (nx == 0 || nx > n) continue;
    if (del[nx][ny]) Merge(k, C(nx, ny));
  }
}
int main() {
  fx[0][1] = fx[0][2] = fx[0][3] = -1, fx[0][4] = fx[0][5] = 0,
  fx[0][6] = fx[0][7] = fx[0][8] = 1;
  fx[1][1] = fx[1][4] = fx[1][6] = -1, fx[1][2] = fx[1][7] = 0,
  fx[1][3] = fx[1][5] = fx[1][8] = 1;
  scanf("%d%d%d", &n, &m, &T);
  int ans = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m + m; j++) f[C(i, j)] = C(i, j);
  for (int i = 1; i <= T; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    tot = 0;
    del[x][y] = del[x][y + m] = 1;
    Link(x, y), Link(x, y + m);
    if (Gf(C(x, y)) == Gf(C(x, y + m))) {
      del[x][y] = del[x][y + m] = 0;
      for (int j = tot; j; j--) f[l1[j]] = l2[j];
    } else
      ans++;
  }
  cout << ans << endl;
  return 0;
}
