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;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

const int MOD = 1e9+7;
const int MAX_N = 3005;

#define F first
#define S second
#define PB push_back
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

int t;
int r, c;
int n;
pii Parent[MAX_N][2*MAX_N];
int Rank[MAX_N][2*MAX_N];
bool Active[MAX_N][2*MAX_N];
bool L[MAX_N][2*MAX_N];
bool R[MAX_N][2*MAX_N];
int dirI[8] = {-1, 1, -1, 0, 1, -1, 0, 1};
int dirJ[8] = {0, 0, 1, 1, 1, -1, -1, -1};

bool inBounds(int i, int j)
{
    return i >= 0 && i < r && j >= 0 && j < 2*c;
}

void initDSU() // global r, c
{
    for(int i = 0; i < r; i++)
    {
        for(int j = 0; j < 2*c; j++)
        {
            Active[i][j] = false;
            Parent[i][j] = {i, j};
            Rank[i][j] = 0;
            L[i][j] = R[i][j] = false;
            if(j == 0)
            {
                L[i][j] = true;
            }
            else if(j == 2*c - 1)
            {
                R[i][j] = true;
            }
        }
    }
}

pii findSet(pii cell)
{
    return (Parent[cell.F][cell.S] == cell ? cell : Parent[cell.F][cell.S] = findSet(Parent[cell.F][cell.S]));
}

bool isSameSet(pii a, pii b)
{
    return findSet(a) == findSet(b);
}

void unionSet(pii a, pii b)
{
    if(isSameSet(a, b))
        return;

    a = findSet(a);
    b = findSet(b);

    if(Rank[a.F][a.S] < Rank[b.F][b.S])
    {
        swap(a, b);
    }

    Parent[b.F][b.S] = a;
    L[a.F][a.S] |= L[b.F][b.S];
    R[a.F][a.S] |= R[b.F][b.S];
    if(Rank[a.F][a.S] == Rank[b.F][b.S])
    {
        Rank[a.F][a.S]++;
    }
}

void solve()
{
    scanf("%d%d%d", &r, &c, &n);

    initDSU();

    int cnt = 0;

    for(int i = 0; i < n; i++)
    {
        int a, b;
        scanf("%d%d", &a, &b);
        a--, b--;

        bool can = true;

        set<pii> MakesL;

        for(int offset : {0, c})
        {
            bool l = L[a][b + offset], r = R[a][b + offset];

            for(int k = 0; k < 8; k++)
            {
                int newI, newJ;
                newI = a + dirI[k];
                newJ = b + dirJ[k] + offset;

                if(inBounds(newI, newJ) && Active[newI][newJ])
                {
                    pii cell = findSet(make_pair(newI, newJ));
                    l |= L[cell.F][cell.S] || (MakesL.count(cell) > 0);
                    r |= R[cell.F][cell.S];
                    if(offset == 0 && (L[cell.F][cell.S] || b == 0) && MakesL.empty())
                    {
                        for(int kk = 0; kk < 8; kk++)
                        {
                            int newII, newJJ;
                            newII = a + dirI[kk];
                            newJJ = b + dirJ[kk];
                            if(inBounds(newII, newJJ) && Active[newII][newJJ])
                            {
                                MakesL.insert(findSet(make_pair(newII, newJJ)));
                                //cout << findSet(make_pair(newII, newJJ)).F << " " << findSet(make_pair(newII, newJJ)).S << ", ";
                            }
                        }
                        //cout << endl;
                    }
                }
            }

            if(l && r)
            {
                can = false;
            }
        }

        if(can)
        {
            Active[a][b] = true;
            Active[a][b + c] = true;
            cnt++;
            for(int k = 0; k < 8; k++)
            {
                int newI, newJ;
                newI = a + dirI[k];
                newJ = b + dirJ[k];

                if(inBounds(newI, newJ) && Active[newI][newJ])
                {
                    unionSet(make_pair(a, b), make_pair(newI, newJ));
                }

                if(inBounds(newI, newJ + c) && Active[newI][newJ + c])
                {
                    unionSet(make_pair(a, b + c), make_pair(newI, newJ + c));
                }

            }
        }

        /*
        for(int ii = 0; ii < r; ii++)
        {
            for(int jj = 0; jj < 2*c; jj++)
            {
                if(!can && ((ii == a && (jj == b || jj == b + c))))
                cout << 'X';
                else
                cout << (Active[ii][jj] ? '*' : '.');
            }
            cout << endl;
        }
        cout << endl;

        for(int ii = 0; ii < r; ii++)
        {
            for(int jj = 0; jj < 2*c; jj++)
            {
                if(Active[ii][jj])
                {
                    pii cell = findSet(make_pair(ii, jj));
                    if(L[cell.F][cell.S])
                    {
                        cout << 'L';
                    }
                    else if(R[cell.F][cell.S])
                    {
                        cout << 'R';
                    }
                    else
                    {
                        cout << '#';
                    }
                }
                else
                {
                    cout << '.';
                }
            }
            cout << endl;
        }
        */
    }

    printf("%d", cnt);
}

int main()
{
    t = 1;
    //scanf("%d", &t);
    while(t--)
    {
        solve();
    }
    return 0;
}

/* INPUT



*/
