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

public class queen2_as 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;
            }
        }

        @Override
        public String toString() {
            return "[" + x + "," + y + "]";
        }
    }

    class RT {
        int n;
        Pair[] a;

        int s;
        int[] t;

        RT(Pair[] a) {
            n = a.length;
            this.a = a;

            s = 1;
            while (s < n) {
                s *= 2;
            }
            t = new int[2 * s - 1];
            for (int i = s - 1; i < s - 1 + n; i++) {
                t[i] = 1;
            }
            for (int i = s - 2; i >= 0; i--) {
                t[i] = t[2 * i + 1] + t[2 * i + 2];
            }
        }

        int find(Pair p) {
            int l = 0;
            int r = n;
            while (l < r - 1) {
                int m = (l + r) / 2;
                if (a[m].compareTo(p) <= 0) {
                    l = m;
                } else {
                    r = m;
                }
            }
            return l;
        }

        int sum(int l, int r) {
            l += s - 1;
            r += s - 1;

            int res = 0;
            while (l <= r) {
                if (l % 2 == 0) {
                    res += t[l++];
                }
                if (r % 2 == 1) {
                    res += t[r--];
                }
                l = (l + 1) / 2 - 1;
                r = (r + 1) / 2 - 1;
            }
            return res;
        }

        void zero(int l) {
            l += s - 1;
            while (l >= 0) {
                t[l]--;
                l = (l + 1) / 2 - 1;
            }
        }
    }

    BufferedReader in;
    StringTokenizer st;

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

    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);

        Pair[] byx = new Pair[n + 1];
        Pair[] byy = new Pair[n + 1];
        Pair[] byxpy = new Pair[n + 1];
        Pair[] byxmy = new Pair[n + 1];
        for (int i = 0; i < n + 1; i++) {
            byx[i] = new Pair(p[i].x, p[i].y);
            byy[i] = new Pair(p[i].y, p[i].x);
            byxpy[i] = new Pair(p[i].x + p[i].y, p[i].x - p[i].y);
            byxmy[i] = new Pair(p[i].x - p[i].y, p[i].x + p[i].y);
        }

        Arrays.sort(byx);
        Arrays.sort(byy);
        Arrays.sort(byxpy);
        Arrays.sort(byxmy);

        RT tx = new RT(byx);
        RT ty = new RT(byy);
        RT txpy = new RT(byxpy);
        RT txmy = new RT(byxmy);


        int a = 0;
        while (a < n) {
            tx.zero(tx.find(new Pair(p[a].x, p[a].y)));
            ty.zero(ty.find(new Pair(p[a].y, p[a].x)));
            txpy.zero(txpy.find(new Pair(p[a].x + p[a].y, p[a].x - p[a].y)));
            txmy.zero(txmy.find(new Pair(p[a].x - p[a].y, p[a].x +  p[a].y)));

            if (p[a].x == p[a + 1].x) {
                int fr = tx.find(new Pair(p[a].x, p[a].y));
                int to = tx.find(new Pair(p[a + 1].x, p[a + 1].y));
                if (fr > to) {
                    int t = fr; fr = to; to = t;
                }
                if (tx.sum(fr, to) != 1) {
                    break;
                }
            } else if (p[a].y == p[a + 1].y) {
                int fr = ty.find(new Pair(p[a].y, p[a].x));
                int to = ty.find(new Pair(p[a + 1].y, p[a + 1].x));
                if (fr > to) {
                    int t = fr; fr = to; to = t;
                }
                if (ty.sum(fr, to) != 1) {
                    break;
                }
            } else if (p[a].x + p[a].y == p[a + 1].x + p[a + 1].y) {
                int fr = txpy.find(new Pair(p[a].x + p[a].y, p[a].x - p[a].y));
                int to = txpy.find(new Pair(p[a + 1].x + p[a + 1].y, p[a + 1].x - p[a + 1].y));
                if (fr > to) {
                    int t = fr; fr = to; to = t;
                }
                if (txpy.sum(fr, to) != 1) {
                    break;
                }
            } else if (p[a].x - p[a].y == p[a + 1].x - p[a + 1].y) {
                int fr = txmy.find(new Pair(p[a].x - p[a].y, p[a].x + p[a].y));
                int to = txmy.find(new Pair(p[a + 1].x - p[a + 1].y, p[a + 1].x + p[a + 1].y));
                if (fr > to) {
                    int t = fr; fr = to; to = t;
                }
                if (txmy.sum(fr, to) != 1) {
                    break;
                }
            } else {
                break;
            }

            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()).start();
    }
}