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;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
namespace Mymath {
long long qp(long long x, long long p, long long mod) {
  long long ans = 1;
  while (p) {
    if (p & 1) ans = ans * x % mod;
    x = x * x % mod;
    p >>= 1;
  }
  return ans;
}
long long inv(long long x, long long mod) { return qp(x, mod - 2, mod); }
long long C(long long N, long long K, long long fact[], long long mod) {
  return fact[N] * inv(fact[K], mod) % mod * inv(fact[N - K], mod) % mod;
}
template <typename Tp>
Tp gcd(Tp A, Tp B) {
  if (B == 0) return A;
  return gcd(B, A % B);
}
template <typename Tp>
Tp lcm(Tp A, Tp B) {
  return A * B / gcd(A, B);
}
};  // namespace Mymath
namespace fwt {
using namespace Mymath;
void FWT(int a[], int n, long long mod) {
  for (int d = 1; d < n; d <<= 1)
    for (int m = d << 1, i = 0; i < n; i += m)
      for (int j = 0; j < d; j++) {
        int x = a[i + j], y = a[i + j + d];
        a[i + j] = (x + y) % mod, a[i + j + d] = (x - y + mod) % mod;
      }
}
void UFWT(int a[], int n, long long mod) {
  long long rev = inv(2, mod);
  for (int d = 1; d < n; d <<= 1)
    for (int m = d << 1, i = 0; i < n; i += m)
      for (int j = 0; j < d; j++) {
        int x = a[i + j], y = a[i + j + d];
        a[i + j] = 1LL * (x + y) * rev % mod,
              a[i + j + d] = (1LL * (x - y) * rev % mod + mod) % mod;
      }
}
void solve(int a[], int b[], int n, long long mod) {
  FWT(a, n, mod);
  FWT(b, n, mod);
  for (int i = 0; i < n; i++) a[i] = 1LL * a[i] * b[i] % mod;
  UFWT(a, n, mod);
}
};  // namespace fwt
const int Maxn = 3005;
bitset<Maxn> f1[Maxn], f2[Maxn];
int id1[Maxn][Maxn], id2[Maxn][Maxn];
int c1, c2;
pair<int, int> par[Maxn][Maxn];
const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
const int dy[] = {1, -1, 0, 0, -1, 1, -1, 1};
int n, m, q;
bool cover[Maxn][Maxn];
pair<int, int> findset(int x, int y) {
  if (make_pair(x, y) == par[x][y]) return make_pair(x, y);
  return par[x][y] = findset(par[x][y].first, par[x][y].second);
}
void Union(pair<int, int> a, pair<int, int> b) {
  a = findset(a.first, a.second);
  b = findset(b.first, b.second);
  if (a == b) return;
  par[b.first][b.second] = a;
  if (!id1[a.first][a.second]) {
    id1[a.first][a.second] = id1[b.first][b.second];
  } else {
    f1[id1[a.first][a.second]] |= f1[id1[b.first][b.second]];
  }
  if (!id2[a.first][a.second]) {
    id2[a.first][a.second] = id2[b.first][b.second];
  } else {
    f2[id2[a.first][a.second]] |= f2[id2[b.first][b.second]];
  }
}
int main() {
  n = read();
  m = read();
  q = read();
  if (m == 1) {
    printf("0\n");
    return 0;
  }
  int ans = 0;
  for (int i = 0; i < q; i++) {
    int x = read(), y = read();
    if (y == 1) {
      bool flag = true;
      for (int j = 0; j < 8; j++) {
        int nx = x + dx[j], ny = y + dy[j];
        if (nx >= 1 && ny >= 1 && nx <= n && ny <= m && cover[nx][ny]) {
          pair<int, int> tmp = findset(nx, ny);
          nx = tmp.first, ny = tmp.second;
          if (f2[id2[nx][ny]][x] || f2[id2[nx][ny]][x + 1] ||
              f2[id2[nx][ny]][x - 1]) {
            flag = false;
            break;
          }
        }
      }
      if (flag) {
        ans++;
        cover[x][y] = true;
        par[x][y] = make_pair(x, y);
        id1[x][y] = ++c1;
        f1[c1][x] = 1;
        for (int j = 0; j < 8; j++) {
          int nx = x + dx[j], ny = y + dy[j];
          if (nx >= 1 && ny >= 1 && nx <= n && ny <= m && cover[nx][ny]) {
            Union(make_pair(x, y), make_pair(nx, ny));
          }
        }
      }
    } else if (y == m) {
      bool flag = true;
      for (int j = 0; j < 8; j++) {
        int nx = x + dx[j], ny = y + dy[j];
        if (nx >= 1 && ny >= 1 && nx <= n && ny <= m && cover[nx][ny]) {
          pair<int, int> tmp = findset(nx, ny);
          nx = tmp.first, ny = tmp.second;
          if (f1[id1[nx][ny]][x] || f1[id1[nx][ny]][x + 1] ||
              f1[id1[nx][ny]][x - 1]) {
            flag = false;
            break;
          }
        }
      }
      if (flag) {
        ans++;
        cover[x][y] = true;
        par[x][y] = make_pair(x, y);
        id2[x][y] = ++c2;
        f2[c2][x] = 1;
        for (int j = 0; j < 8; j++) {
          int nx = x + dx[j], ny = y + dy[j];
          if (nx >= 1 && ny >= 1 && nx <= n && ny <= m && cover[nx][ny]) {
            Union(make_pair(x, y), make_pair(nx, ny));
          }
        }
      }
    } else {
      vector<pair<int, int> > V;
      for (int j = 0; j < 8; j++) {
        int nx = x + dx[j], ny = y + dy[j];
        if (nx >= 1 && ny >= 1 && nx <= n && ny <= m && cover[nx][ny]) {
          V.push_back(findset(nx, ny));
        }
      }
      sort(V.begin(), V.end());
      V.resize(unique(V.begin(), V.end()) - V.begin());
      bitset<Maxn> tmp1, tmp2;
      bool flag = true;
      for (int i = 0; i < V.size(); i++) {
        if (!flag) break;
        tmp1 = f1[id1[V[i].first][V[i].second]];
        tmp1 = tmp1 | (tmp1 << 1) | (tmp1 >> 1);
        for (int j = 0; j < V.size(); j++) {
          if (i == j) continue;
          tmp2 = f2[id2[V[j].first][V[j].second]];
          if ((tmp1 & tmp2) != 0) {
            flag = false;
            break;
          }
        }
      }
      if (flag) {
        ans++;
        cover[x][y] = true;
        par[x][y] = make_pair(x, y);
        for (int j = 0; j < 8; j++) {
          int nx = x + dx[j], ny = y + dy[j];
          if (nx >= 1 && ny >= 1 && nx <= n && ny <= m && cover[nx][ny]) {
            Union(make_pair(x, y), make_pair(nx, ny));
          }
        }
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
