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 <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>

using namespace std;

#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define snuke(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)

#define MAXV 1200010

int V;
int parent[MAXV],rank[MAXV];

int root(int x){
    if(parent[x] != x) parent[x] = root(parent[x]);
    return parent[x];
}

void connect(int x, int y){
    int rx=root(x),ry=root(y);
    if(rx == ry) return;
    if(rank[rx] > rank[ry]) {parent[ry] = rx; rank[rx] += rank[ry];}
    if(rank[rx] <= rank[ry]) {parent[rx] = ry; rank[ry] += rank[rx];}
}

int R,C;
int id[3010][12010];

vector <int> get_neighbor(int r, int c){
    int i,j;
    vector <int> ans;
    for(i=r-1;i<=r+1;i++) for(j=c-1;j<=c+1;j++) if(i >= 0 && i < R && j >= 0 && j < 4*C && id[i][j] != -1) ans.push_back(id[i][j]);
    return ans;
}

bool can_add(int r, int c){
    int i,j;
    vector <int> v1 = get_neighbor(r, C+c);
    vector <int> v2 = get_neighbor(r, 2*C+c);
    REP(i,v1.size()) REP(j,v2.size()) if(root(v1[i]) == root(v2[j])) return false;
    return true;
}

void add(int r, int c){
    int i;
    id[r][c] = V;
    parent[V] = V;
    rank[V] = 1;
    V++;
    vector <int> v = get_neighbor(r, c);
    REP(i,v.size()) connect(id[r][c], v[i]);
}

int main(void){
    int Q,r,c,i,j;
    
    cin >> R >> C >> Q;
    REP(i,R) REP(j,4*C) id[i][j] = -1;
    
    if(C == 1){
        cout << 0 << endl;
        return 0;
    }
    
    int ans = 0;
    REP(i,Q){
        scanf("%d%d", &r, &c); r--; c--;
        if(can_add(r, c)){
            REP(j,4) add(r, C*j+c);
            ans++;
        }
    }
    
    cout << ans << endl;
    
    return 0;
}
