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 INF = 2147483647;
const int maxn = 3010;
const int dx[8] = {1, 1, 1, -1, -1, -1, 0, 0};
const int dy[8] = {0, 1, -1, 0, 1, -1, 1, -1};
int Map[maxn][maxn * 2];
int x, y, N, M, K, pa[maxn * maxn * 2];
int findpa(int x) {
  if (x == 0) return rand();
  if (x == pa[x])
    return x;
  else
    return pa[x] = findpa(pa[x]);
}
int main() {
  int ans = 0;
  cin >> N >> M >> K;
  if (M == 1) return puts("0"), 0;
  for (int i = 1; i <= K; i++) {
    scanf("%d%d", &x, &y);
    if (Map[x][y]) continue;
    int bo = 1;
    for (int k1 = 0; k1 < 8 && bo; k1++)
      for (int k2 = 0; k2 < 8 && bo; k2++) {
        int X1 = x - dx[k1], Y1 = y - dy[k1];
        int X2 = x - dx[k2], Y2 = y - dy[k2] + M;
        if (Map[X1][Y1] && Map[X2][Y2])
          if (findpa((X1 - 1) * (M * 2) + Y1) ==
              findpa((X2 - 1) * (M * 2) + Y2)) {
            bo = 0;
            break;
          }
      }
    if (bo) {
      pa[(x - 1) * (M * 2) + y] = (x - 1) * (M * 2) + y;
      for (int k = 0; k < 8; k++)
        if (Map[x - dx[k]][y - dy[k]]) {
          int t = findpa((x - dx[k] - 1) * (M * 2) + y - dy[k]);
          pa[t] = (x - 1) * (M * 2) + y;
        }
      Map[x][y] = 1;
      y += M;
      pa[(x - 1) * (M * 2) + y] = (x - 1) * (M * 2) + y;
      for (int k = 0; k < 8; k++)
        if (Map[x - dx[k]][y - dy[k]]) {
          int t = findpa((x - dx[k] - 1) * (M * 2) + y - dy[k]);
          pa[t] = (x - 1) * (M * 2) + y;
        }
      Map[x][y] = 1;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
