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>
#pragma comment(linker, "/STACK:512000000")
using namespace std;
template <class T>
inline T sqr(T x) {
  return x * x;
}
template <class T>
inline string tostr(const T &x) {
  stringstream ss;
  ss << x;
  return ss.str();
}
const double EPS = 1e-6;
const int INF = 1000 * 1000 * 1000;
const char CINF = 102;
const long long LINF = INF * 1ll * INF;
const long double PI = 3.1415926535897932384626433832795;
long long gcd(long long a, long long b) { return a ? gcd(b % a, a) : b; }
unsigned int gcd(unsigned int a, unsigned int b) {
  return a ? gcd(b % a, a) : b;
}
const int L = 96;
struct mask {
  unsigned int a[L];
  void clear() { memset(a, 0, sizeof(a)); }
  void set1(int p) { a[p >> 5] |= 1 << (p & 31); }
  mask &operator|=(const mask &b) {
    for (int i = 0; i < (L); ++i) {
      a[i] |= b.a[i];
    }
    return *this;
  }
  bool inters(const mask &b) {
    for (int i = 0; i < (L); ++i) {
      if (a[i] & b.a[i]) return true;
    }
    return false;
  }
};
int A, B, n;
int comp[3100][3100];
int dsu[310000];
pair<mask, mask> cmask[310000];
int dsuget(int a) { return dsu[a] == a ? a : (dsu[a] = dsuget(dsu[a])); }
int main(int argc, char **argv) {
  memset(comp, -1, sizeof(comp));
  cin >> A >> B >> n;
  int res = 0;
  for (int qq = 0; qq < (n); ++qq) {
    int a, b;
    cin >> a >> b;
    comp[a][b] = qq;
    dsu[qq] = qq;
    if (b == 1) {
      cmask[qq].first.set1(a - 1);
      cmask[qq].first.set1(a);
      cmask[qq].first.set1(a + 1);
    }
    if (b == B) {
      cmask[qq].second.set1(a);
    }
    int cs[15];
    int l = 0;
    for (int aa = a - 1; aa <= a + 1; ++aa) {
      for (int bb = b - 1; bb <= b + a; ++bb) {
        if (comp[aa][bb] != -1) cs[l++] = dsuget(comp[aa][bb]);
      }
    }
    sort(cs, cs + l);
    l = (int)(unique(cs, cs + l) - cs);
    pair<mask, mask> nm;
    for (int i = 0; i < (l); ++i) {
      nm.first |= cmask[cs[i]].first;
      nm.second |= cmask[cs[i]].second;
    }
    if (nm.first.inters(nm.second)) {
      comp[a][b] = -1;
    } else {
      ++res;
      cmask[cs[0]] = nm;
      for (int i = 1; i < l; ++i) {
        dsu[cs[i]] = cs[0];
      }
    }
  }
  cout << res;
  return 0;
}
