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

import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskD solver = new TaskD();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskD {
    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int rows = in.nextInt();
        int cols = in.nextInt();
        int n = in.nextInt();
        int[] comp = new int[4 * rows * cols];
        int total = rows * cols;
        Arrays.fill(comp, -1);
        int[] a1 = new int[10];
        int[] a2 = new int[10];
        int res = 0;
        for (int step = 0; step < n; ++step) {
            int r = in.nextInt() - 1;
            int c = in.nextInt() - 1;
            comp[c * rows + r + 2 * total] = c * rows + r + 2 * total;
            comp[c * rows + r + total] = c * rows + r + total;
            int na1 = 0;
            int na2 = 0;
            for (int dr = -1; dr <= 1; ++dr)
                for (int dc = -1; dc <= 1; ++dc) {
                    int r1 = r + dr;
                    int c1 = c + dc + 2 * cols;
                    if (r1 < 0 || r1 >= rows || c1 < 0 || c1 >= 4 * cols || comp[c1 * rows + r1] < 0) {
                    } else {
                        a1[na1++] = get(comp, c1 * rows + r1);
                    }
                    int r2 = r + dr;
                    int c2 = c + dc + cols;
                    if (r2 < 0 || r2 >= rows || c2 < 0 || c2 >= 4 * cols || comp[c2 * rows + r2] < 0) {
                    } else {
                        a2[na2++] = get(comp, c2 * rows + r2);
                    }
                }
            boolean ok = true;
            outer: for (int i = 0; i < na1; ++i)
                for (int j = 0; j < na2; ++j)
                    if (a1[i] == a2[j]) {
                        ok = false;
                        break outer;
                    }
            if (ok) {
                for (int i = 1; i < na1; ++i)
                    comp[a1[i]] = a1[0];
                for (int i = 1; i < na2; ++i)
                    comp[a2[i]] = a2[0];
                ++res;
                comp[c * rows + r + 3 * total] = c * rows + r + 3 * total;
                comp[c * rows + r + 0 * total] = c * rows + r + 0 * total;
                na1 = 0;
                na2 = 0;
                for (int dr = -1; dr <= 1; ++dr)
                    for (int dc = -1; dc <= 1; ++dc) {
                        int r1 = r + dr;
                        int c1 = c + dc + 3 * cols;
                        if (r1 < 0 || r1 >= rows || c1 < 0 || c1 >= 4 * cols || comp[c1 * rows + r1] < 0) {
                        } else {
                            a1[na1++] = get(comp, c1 * rows + r1);
                        }
                        int r2 = r + dr;
                        int c2 = c + dc + 0 * cols;
                        if (r2 < 0 || r2 >= rows || c2 < 0 || c2 >= 4 * cols || comp[c2 * rows + r2] < 0) {
                        } else {
                            a2[na2++] = get(comp, c2 * rows + r2);
                        }
                    }
                for (int i = 1; i < na1; ++i)
                    comp[a1[i]] = a1[0];
                for (int i = 1; i < na2; ++i)
                    comp[a2[i]] = a2[0];
            } else {
                comp[c * rows + r + 2 * total] = -1;
                comp[c * rows + r + total] = -1;
            }
        }
        out.println(res);
    }

    private int get(int[] comp, int at) {
        int root = at;
        while (comp[root] != root) root = comp[root];
        while (comp[at] != root) {
            int nat = comp[at];
            comp[at] = root;
            at = nat;
        }
        return root;
    }
}

class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    }

