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 <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <complex>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cwchar>
#include <cwctype>
#include <exception>
#include <locale>
#include <numeric>
#include <new>
#include <stdexcept>
#include <limits>
#include <valarray>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <list>
#include <utility>
#include <bitset>
#include <algorithm>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define MP make_pair
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int INF=1e9+7;
set<pair<ll,ll> > poi;
map<ll,int> id[2];
int n,Gi[2][100005];
ll pos[2][100005];
set<pair<ll,int> > have[2][100005];
vector<int> res;
inline int ABS(int x){
	return x<0?-x:x;
} 
template<typename T>inline void eerase(set<T> &S,T val){
	S.erase(S.find(val));
}
inline ll getval(int T,int v){
	if(T==0)return pos[0][v]-pos[1][v];
	if(T==1)return pos[0][v]+pos[1][v];
	return 0LL;
}
void init_poi();
void init_have();
void init_Gi();
void erase_vertex(int);
void dfs(int);
void dfs_all(int,int,ll,ll,int);
int getsum(int,int,ll,ll);
ll getans(int,int);
void init_poi(){
	rep(k,n)poi.insert(MP(pos[0][k],pos[1][k]));
	rep(T,2){
		rep(k,n)id[T][getval(T,k)]=-1;
		int cur=0;
		for(map<ll,int>::iterator it=id[T].begin();it!=id[T].end();it++)
		it->second=++cur; 
	} 
}
void init_have(){
	rep(k,n){
		have[0][id[0][getval(0,k)]].insert(MP(pos[0][k],k));
		have[1][id[1][getval(1,k)]].insert(MP(pos[0][k],k));
	}
}
void init_Gi(){
	rep(T,2){
		rep1(k,id[T].size()){
			int cur=0;
			for(set<pair<ll,int> >::iterator it=have[T][k].begin();it!=have[T][k].end();it++)
			Gi[T][it->second]=cur++;
		}
	}
}
void erase_vertex(int v){
	eerase(have[0][id[0][getval(0,v)]],MP(pos[0][v],v));
	eerase(have[1][id[1][getval(1,v)]],MP(pos[0][v],v));
	res.push_back(v);
}
void dfs(int v,int d){
	erase_vertex(v);
	dfs_all(0,id[0][getval(0,v)-d],pos[0][v]-d,pos[0][v],d);
	dfs_all(0,id[0][getval(0,v)+d],pos[0][v],pos[0][v]+d,d);
	dfs_all(1,id[1][getval(1,v)-d],pos[0][v]-d,pos[0][v],d);
	dfs_all(1,id[1][getval(1,v)+d],pos[0][v],pos[0][v]+d,d);
}
void dfs_all(int T,int cid,ll l,ll r,int d){
	for(set<pair<ll,int> >::iterator it=have[T][cid].lower_bound(MP(l,-1));
		it!=have[T][cid].lower_bound(MP(r,INF));it=have[T][cid].lower_bound(MP(it->second,INF)))
	dfs(it->second,d);
}
int haveV(ll x,ll y){
	if(poi.find(MP(x,y))==poi.end())return 0;
	return 1;
}
int getsum(int T,int cid,ll l,ll r){
	set<pair<ll,int> >::iterator it1=have[T][cid].lower_bound(MP(l,-1)),
					 		     it2=have[T][cid].lower_bound(MP(r,INF));
	if(it1==have[T][cid].end()||it2==have[T][cid].begin())return 0;
	else{
		it2--;
		return Gi[T][it2->second]-Gi[T][it1->second]+1;
	}
}
ll getans(int v,int d){
	int ans=getsum(0,id[0][getval(0,v)-d],pos[0][v]-d,pos[0][v])+
	    	getsum(0,id[0][getval(0,v)+d],pos[0][v],pos[0][v]+d)+
	    	getsum(1,id[1][getval(1,v)-d],pos[0][v]-d,pos[0][v])+
	    	getsum(1,id[1][getval(1,v)+d],pos[0][v],pos[0][v]+d);
	return ll(ans-haveV(pos[0][v]-d,pos[1][v])-haveV(pos[0][v]+d,pos[1][v])
				 -haveV(pos[0][v],pos[1][v]-d)-haveV(pos[0][v],pos[1][v]+d));
}
int main(){
	int a,b,d;
	ll ans=0LL;
	scanf("%d%d%d",&n,&a,&b);a--;b--;
	rep(k,n)scanf("%I64d%I64d",&pos[0][k],&pos[1][k]);
	d=ABS(pos[0][a]-pos[0][b])+ABS(pos[1][a]-pos[1][b]);
	init_poi();
	init_have();
	dfs(a,d);
	init_have();
	init_Gi();
	rep(k,res.size())ans+=getans(res[k],d);
	printf("%I64d",ans/2);
	return 0;
}