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;
const int maxs = 18000005;
int fa[maxs], Rank[maxs], n, m, q;
bool vis[3005][6005];
int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
int find(int x) {
  if (fa[x] == x) return x;
  return fa[x] = find(fa[x]);
}
void hb(int x, int y) {
  x = find(x), y = find(y);
  if (x == y) return;
  if (Rank[x] < Rank[y])
    fa[x] = y;
  else {
    fa[y] = x;
    if (Rank[x] == Rank[y]) Rank[x]++;
  }
}
bool judge(int x, int y) {
  return x > 0 && x < n + 1 && y > 0 && y < 2 * m + 1;
}
bool check(int x, int y) { return find(x) == find(y); }
int id(int x, int y) { return (x - 1) * 2 * m + y; }
bool solve(int x, int y) {
  int x1 = x, y1 = y + m;
  for (int i = 0; i < 8; i++) {
    int x2 = x + dx[i], y2 = y + dy[i];
    if (y2 < 1)
      y2 += 2 * m;
    else if (y2 > 2 * m)
      y2 -= 2 * m;
    if (judge(x2, y2) && vis[x2][y2])
      for (int j = 0; j < 8; j++) {
        int x3 = x1 + dx[j], y3 = y1 + dy[j];
        if (judge(x3, y3) && vis[x3][y3])
          if (check(id(x2, y2), id(x3, y3))) return 0;
      }
  }
  return 1;
}
int main() {
  int x, y, ans = 0;
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 0; i < 2 * n * m + 3; i++) fa[i] = i, Rank[i] = 0;
  while (q--) {
    scanf("%d%d", &x, &y);
    if (solve(x, y)) {
      vis[x][y] = vis[x][y + m] = 1;
      ans++;
      for (int i = 0; i < 8; i++) {
        int x1 = x + dx[i], y1 = y + dy[i];
        if (y1 < 1)
          y1 += 2 * m;
        else if (y1 > 2 * m)
          y1 -= 2 * m;
        if (judge(x1, y1) && vis[x1][y1]) hb(id(x, y), id(x1, y1));
        y1 += m;
        if (y1 < 1)
          y1 += 2 * m;
        else if (y1 > 2 * m)
          y1 -= 2 * m;
        if (judge(x1, y1) && vis[x1][y1]) hb(id(x, y + m), id(x1, y1));
      }
    }
  }
  printf("%d", ans);
  return 0;
}
