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;
pair<int, int> field[3010][6010];
int r, c, n, ans;
inline pair<int, int> dsu_find(int x, int y) {
  if (field[x][y] == make_pair(x, y)) return make_pair(x, y);
  pair<int, int> res = dsu_find(field[x][y].first, field[x][y].second);
  field[x][y] = res;
  return res;
}
inline void dsu_unite(int x1, int y1, int x2, int y2) {
  pair<int, int> a = dsu_find(x1, y1), b = dsu_find(x2, y2);
  if (a != b) {
    if ((rand() & 1) == 0)
      field[b.first][b.second] = a;
    else
      field[a.first][a.second] = b;
  }
}
int main() {
  scanf("%d%d%d", &r, &c, &n);
  if (c == 1) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    int xx, yy;
    scanf("%d%d", &xx, &yy);
    bool fl = 0;
    int x1, y1, x2, y2;
    for (int dx1 = -1; dx1 <= 1; dx1++)
      for (int dy1 = -1; dy1 <= 1; dy1++) {
        if (dx1 == 0 && dy1 == 0) continue;
        x1 = xx + dx1;
        y1 = yy + dy1;
        if (!(x1 >= 1 && x1 <= r && y1 >= 1 && y1 <= c + c &&
              field[x1][y1] != make_pair(0, 0)))
          continue;
        for (int dx2 = -1; dx2 <= 1; dx2++)
          for (int dy2 = -1; dy2 <= 1; dy2++) {
            if (dx2 == 0 && dy2 == 0) continue;
            x2 = xx + dx2;
            y2 = yy + dy2 + c;
            if (!(x2 >= 1 && x2 <= r && y2 >= 1 && y2 <= c + c &&
                  field[x2][y2] != make_pair(0, 0)))
              continue;
            if (dsu_find(x1, y1) == dsu_find(x2, y2)) fl = 1;
          }
      }
    if (fl == 1) continue;
    ans++;
    field[xx][yy] = make_pair(xx, yy);
    field[xx][yy + c] = make_pair(xx, yy + c);
    for (int dx = -1; dx <= 1; dx++)
      for (int dy = -1; dy <= 1; dy++) {
        if (dx == 0 && dy == 0) continue;
        int x, y;
        x = xx + dx;
        y = yy + dy;
        if ((x >= 1 && x <= r && y >= 1 && y <= c + c &&
             field[x][y] != make_pair(0, 0)))
          dsu_unite(xx, yy, x, y);
        x = xx + dx;
        y = yy + dy + c;
        if ((x >= 1 && x <= r && y >= 1 && y <= c + c &&
             field[x][y] != make_pair(0, 0)))
          dsu_unite(xx, yy + c, x, y);
      }
  }
  cout << ans << endl;
  return 0;
}
