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 C++14 (GCC 5.4.1) (judge verdict: Runtime Error)

#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<ctype.h>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<math.h>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<stdio.h>
#include<stdlib.h>
#include<streambuf>
#include<string.h>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#define sz1 50
#define sz2 125
#define MD1 233
#define MD2 179
#define x first
#define y second
#define m_p make_pair
using namespace std;
int cox[100010],coy[100010];
bool rch[100010];
bool usd[266][266];
inline int absi(int a){
	return (a>0)?a:-a;
}
inline int dist(int a,int b){
	return (absi(cox[a]-cox[b])+absi(coy[a]-coy[b]));
}
int main(void){
	int n,a,b;
	scanf("%d%d%d",&n,&a,&b);
	vector<pair<int,int> > v;
	for (int i=1;i<=n;i++){
		scanf("%d%d",&cox[i],&coy[i]);
	}
	for (int i=1;i<=n;i++){
		v.push_back(m_p(dist(a,i),i));
	}
	sort(v.begin(),v.end());
	int hd=0,tl=0,oth=0,d=dist(a,b);
	long long res=0;
	rch[a]=1;
	while(oth<n&&v[0].x+v[oth].x<d){
		oth++;
	}
	if (oth==n) oth=n-1;
	for (int i=0;i<n;i++){
		if (!rch[v[i].y]) continue;
		while(v[i].x-v[hd].x>d){
			hd++;
		}
		while(tl<n&&v[tl].x-v[i].x<=d){
			tl++;
		}
		while(v[i].x+v[oth].x>=d){
			oth--;
		}
		for (int j=max(oth+1,hd);j<tl;j++){
			int aa=v[i].y,bb=v[j].y;
			if (dist(aa,bb)==d){
				rch[bb]=1;
				if (aa>bb) swap(aa,bb);
				if (!usd[(aa*sz1+bb)%MD1][(aa*sz2+bb)%MD2]){
					usd[(aa*sz1+bb)%MD1][(aa*sz2+bb)%MD2]=1;
					res++;
				}
			}
		}
	}
	printf("%lld",res);
	return 0;
}