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;
const int DY[] = {-1, -1, 0, 1, 1, 1, 0, -1};
const int DX[] = {0, 1, 1, 1, 0, -1, -1, -1};
int r, c;
pair<int, int> repr(vector<vector<pair<int, int> > >& fath, int y, int x) {
  if (fath[y][x].first == -1) return pair<int, int>(y, x);
  return fath[y][x] = repr(fath, fath[y][x].first, fath[y][x].second);
}
void merge_with_neighbours(const vector<vector<bool> >& land,
                           vector<vector<pair<int, int> > >& fath, int y,
                           int x) {
  pair<int, int> rep = repr(fath, y, x);
  for (int d = 0; d < 8; ++d) {
    int ay = y + DY[d];
    int ax = (x + DX[d] + 2 * c) % (2 * c);
    if (ay < 0 || ay >= r) continue;
    if (!land[ay][ax]) continue;
    pair<int, int> arep = repr(fath, ay, ax);
    if (rep != arep) {
      fath[arep.first][arep.second] = rep;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> r >> c >> n;
  vector<vector<pair<int, int> > > fath(
      r, vector<pair<int, int> >(2 * c, pair<int, int>(-1, -1)));
  vector<vector<bool> > land(r, vector<bool>(2 * c, false));
  int ans = 0;
  for (int cell = 0; cell < n; ++cell) {
    int y, x;
    cin >> y >> x;
    --y;
    --x;
    bool turn = true;
    for (int d = 0; d < 8 && turn; ++d) {
      int ay = y + DY[d];
      int ax = (x + DX[d] + 2 * c) % (2 * c);
      if (ay < 0 || ay >= r) continue;
      if (ay == y && ax == x + c) {
        turn = false;
        break;
      }
      if (!land[ay][ax]) continue;
      pair<int, int> rep = repr(fath, ay, ax);
      for (int d2 = 0; d2 < 8; ++d2) {
        int ay2 = y + DY[d2];
        int ax2 = (x + c + DX[d2] + 2 * c) % (2 * c);
        if (ay2 < 0 || ay2 >= r) continue;
        if (!land[ay2][ax2]) continue;
        pair<int, int> rep2 = repr(fath, ay2, ax2);
        if (rep == rep2) {
          turn = false;
          break;
        }
      }
    }
    if (turn) {
      ++ans;
      land[y][x] = true;
      merge_with_neighbours(land, fath, y, x);
      land[y][x + c] = true;
      merge_with_neighbours(land, fath, y, x + c);
    }
  }
  cout << ans << endl;
}
