Problem:
Score : 900 points

Problem Statement

There are N pinholes on the xy-plane. The i-th pinhole is located at (x_i,y_i).

We will denote the Manhattan distance between the i-th and j-th pinholes as d(i,j)(=|x_i-x_j|+|y_i-y_j|).

You have a peculiar pair of compasses, called Manhattan Compass.
This instrument always points at two of the pinholes.
The two legs of the compass are indistinguishable, thus we do not distinguish the following two states: the state where the compass points at the p-th and q-th pinholes, and the state where it points at the q-th and p-th pinholes.

When the compass points at the p-th and q-th pinholes and d(p,q)=d(p,r), one of the legs can be moved so that the compass will point at the p-th and r-th pinholes.

Initially, the compass points at the a-th and b-th pinholes.
Find the number of the pairs of pinholes that can be pointed by the compass.

Constraints

2≦N≦10^5

1≦x_i, y_i≦10^9

1≦a < b≦N

When i ≠ j, (x_i, y_i) ≠ (x_j, y_j)

x_i and y_i are integers.

Input

The input is given from Standard Input in the following format:

N a b
x_1 y_1
:
x_N y_N

Output

Print the number of the pairs of pinholes that can be pointed by the compass.

Sample Input 1

5 1 2
1 1
4 3
6 1
5 5
4 8

Sample Output 1

4

Initially, the compass points at the first and second pinholes.

Since d(1,2) = d(1,3), the compass can be moved so that it will point at the first and third pinholes.

Since d(1,3) = d(3,4), the compass can also point at the third and fourth pinholes.

Since d(1,2) = d(2,5), the compass can also point at the second and fifth pinholes.

No other pairs of pinholes can be pointed by the compass, thus the answer is 4.

Sample Input 2

6 2 3
1 3
5 3
3 5
8 4
4 7
2 5

Sample Output 2

4

Sample Input 3

8 1 2
1 5
4 3
8 2
4 7
8 8
3 3
6 6
4 8

Sample Output 3

7

Solution in Rust (1.15.1) (judge verdict: Accepted)

//---------- begin union_find ----------
mod union_find {
    pub struct UF {
        p: Vec<i32>,
    }
    #[allow(dead_code)]
    impl UF {
        pub fn new(n: usize) -> UF {
            UF {p: vec![-1; n] }
        }
        pub fn init(&mut self) {
            for p in self.p.iter_mut() {
                *p = -1;
            }
        }
        pub fn root(&mut self, mut x: usize) -> usize {
            while self.p[x] >= 0 {
                x = self.p[x] as usize;
            }
            x
        }
        pub fn same(&mut self, x: usize, y: usize) -> bool {
            self.root(x) == self.root(y)
        }
        pub fn unite(&mut self, mut x: usize, mut y: usize) {
            x = self.root(x);
            y = self.root(y);
            if x == y {
                return;
            }
            if self.p[x] > self.p[y] {
                let s = x;
                x = y;
                y = s;
            }
            self.p[x] += self.p[y];
            self.p[y] = x as i32;
        }
        pub fn get_size(&mut self, x: usize) -> usize {
            let r = self.root(x);
            (-self.p[r]) as usize
        }
    }
}
//---------- end union_find ----------

use std::io::Read;
use std::cmp::max;

fn func(p: (i64, i64, usize)) -> i64 {
    p.0 + p.1
}

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: usize = it.next().unwrap().parse().unwrap();
    let a = it.next().unwrap().parse::<usize>().unwrap() - 1;
    let b = it.next().unwrap().parse::<usize>().unwrap() - 1;
    let mut p = Vec::with_capacity(n);
    for i in 0..n {
        let x: i64 = it.next().unwrap().parse().unwrap();
        let y: i64 = it.next().unwrap().parse().unwrap();
        p.push((x, y, i));
    }
    let d = (p[a].0 - p[b].0).abs() + (p[a].1 - p[b].1).abs();
    let mut u = union_find::UF::new(n);
    for _ in 0..4 {
        p.sort_by_key(|&p| (func(p), p.0));
        let mut l = 0;
        for i in 0..n {
            l = max(l, i + 1);
            while l < n && (func(p[l]) < func(p[i]) + d || (func(p[l]) == func(p[i]) + d && p[l].0 <= p[i].0)) {
                l += 1;
            }
            while l < n && func(p[l]) == func(p[i]) + d && p[l].1 >= p[i].1 {
                u.unite(p[i].2, p[l].2);
                l += 1;
            }
            l -= 1;
        }
        for p in p.iter_mut() {
            *p = (p.1, -p.0, p.2);
        }
    }
    let mut ans = 0;
    for _ in 0..4 {
        p.sort_by_key(|&p| (func(p), p.0));
        let mut l = 0;
        let mut r = 0;
        for i in 0..n {
            if !u.same(a, p[i].2) {
                continue;
            }
            l = max(l, i + 1);
            while l < n && (func(p[l]) < func(p[i]) + d || (func(p[l]) == func(p[i]) + d && p[l].0 <= p[i].0)) {
                l += 1;
            }
            r = max(l, r);
            while r < n && func(p[r]) == func(p[i]) + d && p[r].1 >= p[i].1 {
                r += 1;
            }
            ans += r - l;
        }
        for p in p.iter_mut() {
            *p = (p.1, -p.0, p.2);
        }
    }
    ans /= 2;
    println!("{}", ans);
}

fn main() {
    run();
}