import java.io.*;
import java.util.*;

public class queen2_as_dumb implements Runnable {

    class Pair implements Comparable<Pair> {
        int x;
        int y;

        public Pair(int x, int y) {
            this.x = x;
            this.y = y;
        }

        public int compareTo(Pair o) {
            if (x < o.x) {
                return -1;
            } else if (x > o.x) {
                return 1;
            } else if (y < o.y) {
                return -1;
            } else if (y > o.y) {
                return 1;
            } else {
                return 0;
            }
        }
    }

    BufferedReader in;
    StringTokenizer st;

    int nextInt() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return Integer.parseInt(st.nextToken());
    }

    boolean between(int x, int y, int z) {
        return (x <= y && y <= z) || (z <= y && y <= x);
    }

    boolean between(Pair x, Pair y, Pair z) {
        if (x.x == y.x && z.x == y.x && between(x.y, y.y, z.y)) {
            return true;
        }
        if (x.y == y.y && z.y == y.y && between(x.x, y.x, z.x)) {
            return true;
        }
        if (x.x + x.y == y.x + y.y && z.x + z.y == y.x + y.y && between(x.x - x.y, y.x - y.y, z.x - z.y)) {
            return true;
        }
        if (x.x - x.y == y.x - y.y && z.x - z.y == y.x - y.y && between(x.x + x.y, y.x + y.y, z.x + z.y)) {
            return true;
        }
        return false;
    }

    public void solve() throws IOException {
        in = new BufferedReader(new FileReader("queen2.in"));
        PrintWriter out = new PrintWriter(new File("queen2.out"));

        int n = nextInt();
        Pair[] p = new Pair[n + 1];
        for (int i = 0; i < n; i++) {
            p[i + 1] = new Pair(nextInt(), nextInt());
        }
        p[0] = new Pair(0, 0);

        int a = 0;
        search:
        while (a < n) {
            if (p[a].x == p[a + 1].x || p[a].y == p[a + 1].y ||
                    p[a].x + p[a].y == p[a + 1].x + p[a + 1].y ||
                    p[a].x - p[a].y == p[a + 1].x - p[a + 1].y) {
                for (int i = a + 2; i <= n; i++) {
                    if (between(p[a], p[i], p[a + 1])) {
                        break search;
                    }
                }
            } else {
            	break search;
            }

            a++;
        }

        out.println(a);

        in.close();
        out.close();
    }

    public void run() {
        try {
            solve();
        } catch (IOException e) {
            System.exit(64);
        }
    }

    public static void main(String[] arg) throws IOException {
        new Thread(new queen2_as_dumb()).start();
    }
}