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 v[18000005];
char connToRight[18000005];
char connToLeft[18000005];
int used[3005][6005];
int get(int i) {
  if (v[i] == i)
    return i;
  else
    return v[i] = get(v[i]);
}
void unite(int a, int b) {
  int i = get(a);
  int j = get(b);
  if (i != j) {
    if (rand() & 1) swap(i, j);
    v[i] = j;
  }
}
int r, c, n, cnt;
int cc(int x, int y) { return x * c * 2 + y; }
int main(int argc, char **argv) {
  scanf("%d %d %d", &r, &c, &n);
  cnt = r * c * 2;
  for (int i = 0; i < cnt; i++) v[i] = i;
  if (c == 1) {
    cout << 0;
    return 0;
  }
  for (int i = 0; i < r; i++) {
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    x--;
    y--;
    int left = get(cc(0, 0));
    int right = get(cc(0, 2 * c - 1));
    bool leftc[2];
    bool rightc[2];
    bool middle = false;
    bool good = true;
    leftc[0] = (y == 0);
    leftc[1] = 0;
    rightc[0] = 0;
    rightc[1] = ((y + c) == (2 * c - 1));
    map<int, int> mm;
    for (int h = 0; h < 2; h++) {
      for (int dx = -1; dx <= 1; dx++) {
        for (int dy = -1; dy <= 1; dy++) {
          int xx = x + dx;
          int yy = y + dy + c * h;
          if (0 <= xx && xx < r && 0 <= yy && yy < c * 2) {
            if (used[xx][yy]) {
              mm[get(cc(xx, yy))] |= 1 << h;
            }
          }
        }
      }
    }
    for (map<int, int>::iterator it = mm.begin(); it != mm.end(); it++) {
      if (it->second == 3) middle = true;
    }
    if (!(middle)) {
      ans++;
      for (int h = 0; h < 2; h++) {
        for (int dx = -1; dx <= 1; dx++) {
          for (int dy = -1; dy <= 1; dy++) {
            int xx = x + dx;
            int yy = y + dy + c * h;
            if (0 <= xx && xx < r && 0 <= yy && yy < c * 2) {
              if (used[xx][yy]) {
                unite(cc(xx, yy), cc(x, y + c * h));
              }
            }
          }
        }
      }
      used[x][y] = true;
      used[x][y + c] = true;
    }
  }
  cout << ans;
  return 0;
}
