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.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;

/**
 * Date: 23.06.13 at 15:29
 *
 * @author Nickolay Polyarniy aka PolarNick
 */
public class ProblemD {

    int r;
    int c;
    Point[][] a;

    public void solve() throws Exception {
        r = nextInt();
        c = nextInt();
        int n = nextInt();
        if (c != 1) {
            a = new Point[2 * c + 2][r + 2];
            int[] dx = new int[]{0, 1, 1, 1, 0, -1, -1, -1};
            int[] dy = new int[]{-1, -1, 0, 1, 1, 1, 0, -1};
            int res = 0;
            for (int tmp = 0; tmp < n; tmp++) {
                int y = nextInt();
                int x = nextInt();
                boolean bad = false;
                for (int i = 0; i < 8 && !bad; i++) {
                    Point one = a[(x + dx[i] + 2 * c - 1) % (2 * c) + 1][y + dy[i]];
                    for (int j = 0; j < 8 && !bad; j++) {
                        Point two = a[(x + c + dx[j] + 2 * c - 1) % (2 * c) + 1][y + dy[j]];
                        if (one != null && two != null) {
                            if (get(one) == get(two)) {
                                bad = true;
                            }
                        }
                    }
                }
                if (!bad) {
                    res++;
                    a[x][y] = new Point(x, y);
                    for (int i = 0; i < 8; i++) {
                        Point one = a[(x + dx[i] + 2 * c - 1) % (2 * c) + 1][y + dy[i]];
                        if (one != null && one.x >= 1 && one.x <= 2 * c && one.y >= 1 && one.y <= r) {
                            union(one, a[x][y]);
                        }
                    }
                    a[x + c][y] = new Point(x + c, y);
                    for (int i = 0; i < 8; i++) {
                        Point two = a[(x + c + dx[i] + 2 * c - 1) % (2 * c) + 1][y + dy[i]];
                        if (two != null && two.x >= 1 && two.x <= 2 * c && two.y >= 1 && two.y <= r) {
                            union(two, a[x + c][y]);
                        }
                    }
                } else {
//                    out.println(" " + x + " " + y);
                }
//                out.println(x+":"+y+" "+foo());
            }
            out.println(res);
        } else {
            out.println(0);
        }
    }

    String foo() {
        String res = "";
        ArrayList<Point> ar = new ArrayList<>();
        for (int y = 0; y < a.length; y++) {
            for (int x = 0; x < a[0].length; x++) {
                if (a[y][x] != null) {
                    ar.add(a[y][x]);
                }
            }
        }
        boolean[] was = new boolean[ar.size()];
        for (int i = 0; i < ar.size(); i++) {
            Point p = ar.get(i);
            if (was[i]) continue;
            was[i] = true;
            ArrayList<Point> ar2 = new ArrayList<>();
            for (int j = 0; j < ar.size(); j++) {
                Point p2 = ar.get(j);
                if (p2 != p) {
                    if (get(p) == get(p2)) {
                        ar2.add(p2);
                        was[j] = true;
                    }
                }
            }

            ar2.add(p);
            Collections.sort(ar2);
            for (int j = 0; j < ar2.size(); j++) {
                res += ar2.get(j);
            }
            for (int j = 1; j < ar2.size(); j++) {
                if (ar2.get(j).x - ar2.get(j - 1).x > 1) {
                    out.println("WARN");
                }
            }
            res += " | ";

        }
        return res;
    }

    public class Point implements Comparable<Point> {
        int x;
        int y;
        Point p;
        int h = 1;

        public Point(int x, int y) {
            this.x = x;
            this.y = y;
            p = null;
        }

        public int getH() {
            return get(this).h;
        }

        @Override
        public String toString() {
            return "{" +
                    "x=" + x +
                    ", y=" + y +
                    ", p=" + (p == null ? "null" : p.x + " " + p.y) +
                    "}";
        }

        @Override
        public int compareTo(Point o) {
            if (x < o.x) return -1;
            if (x > o.x) return 1;
            if (y < o.y) return -1;
            if (y > o.y) return 1;
            return 0;
        }
    }

    public void union(Point p1, Point p2) {
//        out.println("U1 "+p1+" "+p2);
        Point o1 = p1;
        Point o2 = p2;
        p1 = get(p1);
        p2 = get(p2);
        if (p1 != p2) {
            if (p1.getH() < p2.getH()) {
                p2.p = p1;
                p1.h = Math.max(p1.h, p2.h + 1);
            } else {
                p1.p = p2;
                p2.h = Math.max(p2.h, p1.h + 1);
            }
        }
//        out.println("U2 "+p1+" "+p2);
    }

    public Point get(Point p) {
//        out.println("G1 "+p);
        if (p.p == null) {
            return p;
        }
        p.p = get(p.p);
//        out.println("G2 "+p);
        return p.p;
    }

    public static void main(String[] args) throws Exception {
        ProblemD problem = new ProblemD();
        problem.solve();
        problem.close();
    }

    BufferedReader in;
    PrintWriter out;
    String curLine;
    StringTokenizer tok;
    final String delimeter = " ";
    final String endOfFile = "";

    public ProblemD(BufferedReader in, PrintWriter out) throws Exception {
        this.in = in;
        this.out = out;
        curLine = in.readLine();
        if (curLine == null || curLine == endOfFile) {
            tok = null;
        } else {
            tok = new StringTokenizer(curLine, delimeter);
        }
    }

    public ProblemD() throws Exception {
        this(new BufferedReader(new InputStreamReader(System.in)),
                new PrintWriter(System.out));
    }

    public ProblemD(String filename) throws Exception {
        this(new BufferedReader(new FileReader(filename + ".in")),
                new PrintWriter(filename + ".out"));
    }

    public boolean hasMore() throws Exception {
        if (tok == null || curLine == null) {
            return false;
        } else {
            while (!tok.hasMoreTokens()) {
                curLine = in.readLine();
                if (curLine == null || curLine.equalsIgnoreCase(endOfFile)) {
                    tok = null;
                    return false;
                } else {
                    tok = new StringTokenizer(curLine);
                }
            }
            return true;
        }
    }

    public String nextWord() throws Exception {
        if (!hasMore()) {
            return null;
        } else {
            return tok.nextToken();
        }
    }

    public int nextInt() throws Exception {
        return Integer.parseInt(nextWord());
    }

    public long nextLong() throws Exception {
        return Long.parseLong(nextWord());
    }

    public int[] readIntArray(int n) throws Exception {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = nextInt();
        }
        return res;
    }

    public void close() throws Exception {
        in.close();
        out.close();
    }

}
