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:1024000000,1024000000")
using namespace std;
const int Maxn = 3100, Maxm = 100005, Mo = 1000000007,
          sp[8][2] = {{0, 1}, {0, -1},  {1, 0},  {-1, 0},
                      {1, 1}, {-1, -1}, {1, -1}, {-1, 1}};
const long long oo = INT_MAX >> 2;
struct Tree {
  int l, r, cnt;
};
struct edge {
  int u, v, len;
};
struct point {
  long long x, y, id;
};
typedef int IArr[Maxn * Maxn * 2];
typedef long long LArr[Maxn];
typedef double DArr[Maxn];
IArr f;
long long ans;
int n, m, i, j, t, c, x, y;
int mp[Maxn * 2][Maxn];
int gf(int w) {
  if (f[w] == w) return w;
  return f[w] = gf(f[w]);
}
int in(int x, int y) { return (x >= 1 && x <= n && y >= 1 && y <= m * 2); }
void fd(vector<int>& p, int x, int y) {
  for (int i = 0; i < 8; i++) {
    int cx = x + sp[i][0];
    int cy = y + sp[i][1];
    if (!in(cx, cy) || !mp[cx][cy]) continue;
    int a = gf(mp[cx][cy]);
    p.push_back((a));
  }
}
int work(int x1, int y1, int x2, int y2) {
  if (!in(x2, y2)) return 0;
  vector<int> p1, p2;
  fd(p1, x1, y1);
  fd(p2, x2, y2);
  vector<int>::iterator i = p1.begin(), j;
  for (; i != p1.end(); i++)
    for (j = p2.begin(); j != p2.end(); j++)
      if (*i == *j) return 0;
  return 1;
}
int ck(int x, int y) {
  return work(x, y, x, y + m - 1) || work(x, y, x + 1, y + m - 1) ||
         work(x, y, x - 1, y + m - 1);
}
void alt(int id, int x, int y) {
  mp[x][y] = id;
  for (int i = 0; i < 8; i++) {
    int cx = x + sp[i][0];
    int cy = y + sp[i][1];
    if (!in(cx, cy) || !mp[cx][cy]) continue;
    int a = gf(mp[cx][cy]);
    f[a] = id;
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> m >> c;
  if (m == 1) {
    cout << 0 << endl;
    return 0;
  }
  for (i = 1; i <= c; i++) {
    cin >> x >> y;
    f[i] = i;
    f[i + c] = i + c;
    int p = ck(x, y);
    if (!p) {
      p = p;
    }
    if (ck(x, y)) {
      ans++;
      alt(i, x, y);
      alt(i + c, x, y + m);
    }
  }
  cout << ans << endl;
}
