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 dx[] = {-1, 0, 1, -1, 1, -1, 0, 1};
const int dy[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int n, m, q, ans;
bool mark[3030][3030 << 1];
namespace Union_Find_Set {
pair<int, int> fa[3030][3030];
int rank[3030][3030];
pair<int, int> Find(pair<int, int> x) {
  if (fa[x.first][x.second] == make_pair(0, 0) || fa[x.first][x.second] == x)
    return fa[x.first][x.second] = x;
  return fa[x.first][x.second] = Find(fa[x.first][x.second]);
}
void Union(pair<int, int> x, pair<int, int> y) {
  x = Find(x);
  y = Find(y);
  if (x == y) return;
  if (rank[x.first][x.second] > rank[y.first][y.second]) swap(x, y);
  if (rank[x.first][x.second] == rank[y.first][y.second])
    ++rank[y.first][y.second];
  fa[x.first][x.second] = y;
}
}  // namespace Union_Find_Set
int main() {
  using namespace Union_Find_Set;
  int i, j, x, y;
  cin >> n >> m >> q;
  if (m == 1) {
    puts("0");
    return 0;
  }
  for (i = 1; i <= q; i++) {
    scanf("%d%d", &x, &y);
    if (mark[x][y]) continue;
    static pair<int, int> stack1[10], stack2[10];
    int top1 = 0, top2 = 0;
    mark[x][y] = true;
    mark[x][y + m] = true;
    for (j = 0; j < 8; j++) {
      int xx = x + dx[j], yy = y + dy[j], _yy = y + dy[j] + m;
      if (xx == 0 || xx == n + 1) continue;
      if (yy != 0 && mark[xx][yy]) stack1[++top1] = Find(make_pair(xx, yy));
      if (_yy != m + m + 1 && mark[xx][_yy])
        stack2[++top2] = Find(make_pair(xx, _yy));
    }
    bool flag = false;
    sort(stack1 + 1, stack1 + top1 + 1);
    sort(stack2 + 1, stack2 + top2 + 1);
    while (top1 && top2) {
      if (stack1[top1] == stack2[top2]) {
        flag = true;
        break;
      }
      if (stack1[top1] > stack2[top2])
        top1--;
      else
        top2--;
    }
    if (flag) {
      mark[x][y] = false;
      mark[x][y + m] = false;
      continue;
    }
    ++ans;
    for (j = 0; j < 8; j++) {
      int xx = x + dx[j], yy = y + dy[j], _yy = y + dy[j] + m;
      if (xx == 0 || xx == n + 1) continue;
      if (yy != 0 && mark[xx][yy]) Union(make_pair(x, y), make_pair(xx, yy));
      if (_yy != m + m + 1 && mark[xx][_yy])
        Union(make_pair(x, y + m), make_pair(xx, _yy));
    }
  }
  cout << ans << endl;
  return 0;
}
