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, a[3010][6010], fa[18010000];
int dx[9] = {-1, -1, -1, 0, 0, 1, 1, 1}, dy[9] = {-1, 0, 1, -1, 1, -1, 0, 1};
inline int read() {
  int x = 0, f = 0;
  char ch = getchar();
  while (!isdigit(ch)) f = ch == '-', ch = getchar();
  while (isdigit(ch)) x = (x << 3) + (x << 1) + ch - 48, ch = getchar();
  return f ? -x : x;
}
inline int find(int x) { return fa[x] == x ? x : fa[x] = find(fa[x]); }
inline int calc(int x, int y) { return (x - 1) * m * 2 + y; }
int main() {
  int ans = 0;
  n = read(), m = read();
  int Q = read();
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= 2 * m; j++) fa[calc(i, j)] = calc(i, j);
  if (m == 1) {
    puts("0");
    return 0;
  }
  while (Q--) {
    int x = read(), y = read();
    int flag = 0;
    for (int i = 0; i < 8; i++) {
      int xx = x + dx[i], yy = y + dy[i];
      if (yy == 0) yy = 2 * m;
      if (xx < 1 || xx > n || !a[xx][yy]) continue;
      for (int j = 0; j < 8; j++) {
        int xxx = x + dx[j], yyy = y + m + dy[j];
        if (yyy > 2 * m) yyy = 1;
        if (xxx < 1 || xxx > n || !a[xxx][yyy]) continue;
        if (find(calc(xx, yy)) == find(calc(xxx, yyy))) {
          flag = 1;
          break;
        }
      }
    }
    if (flag) continue;
    a[x][y] = a[x][y + m] = 1;
    ans++;
    int fx1 = find(calc(x, y)), fx2 = find(calc(x, y + m));
    for (int i = 0; i < 8; i++) {
      int xx = x + dx[i], yy = y + dy[i];
      if (yy > m) {
        if (a[xx][yy]) fa[find(calc(xx, yy))] = fx1;
        if (a[xx][1]) fa[find(calc(xx, 1))] = fx2;
      } else if (yy < 1) {
        if (a[xx][yy + m]) fa[find(calc(xx, yy + m))] = fx2;
        if (a[xx][2 * m]) fa[find(calc(xx, 2 * m))] = fx1;
      } else {
        if (a[xx][yy]) fa[find(calc(xx, yy))] = fx1;
        if (a[xx][yy + m]) fa[find(calc(xx, yy + m))] = fx2;
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
