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: Wrong Answer)

#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<set>
#include<map>
#define sqr(x) (x)*(x)
#define btoe(v) v.begin(),v.end()
using namespace std;
long long n,m,a,b,i,j,dax[100005],day[100005],used[100005],ans,x,y,dis,cntx,cnty,itr[100005],itc[100005];
set<pair<long long,int>/**/> r1[100005],c1[100005];
vector<long long> r2[100005],c2[100005];
//vector<long long> lsx,lsy;
map<long long,long long> mpr,mpc;
void dfs(int x)
{
	if (used[x]) return;
	//cerr<<x<<":"<<endl;
	used[x]=1;
	r1[dax[x]].erase(make_pair(itc[day[x]],x));
	c1[day[x]].erase(make_pair(itr[dax[x]],x));
	long long xx=dax[x],yy=day[x];
	int i;
	set<pair<long long,int>/**/>::iterator lb;
	set<pair<long long,int>/**/>::iterator ub;
	vector<long long>::iterator vlb;
	vector<long long>::iterator vub;
	if (mpr.count(itr[xx]+dis))
	{
		lb=r1[mpr[itr[xx]+dis]].lower_bound(make_pair(itc[yy]-dis,0));
		ub=r1[mpr[itr[xx]+dis]].upper_bound(make_pair(itc[yy]+dis,1e8));
		for (set<pair<long long,int>/**/>::iterator it=lb;it->first<=itc[yy]+dis;it=r1[mpr[itr[xx]+dis]].lower_bound(make_pair(itc[yy]-dis,0))) 
		{
			if (it->second&&(it->first<=itc[yy]+dis))
			{
				//cerr<<it->second<<endl;
				dfs(it->second);
			}
			else break;
		}
		vlb=lower_bound(btoe(r2[mpr[itr[xx]+dis]]),itc[yy]-dis);
		vub=upper_bound(btoe(r2[mpr[itr[xx]+dis]]),itc[yy]+dis-1);
		ans+=vub-vlb;
		/*for (vector<long long>::iterator it=vlb;it!=vub;it++)
		{
			//cerr<<itr[xx]<<' '<<itc[yy]<<' '<<itr[xx]+dis<<' '<<*it<<endl;
		}*/
	}
	if (mpr.count(itr[xx]-dis))
	{
		lb=r1[mpr[itr[xx]-dis]].lower_bound(make_pair(itc[yy]-dis,0));
		ub=r1[mpr[itr[xx]-dis]].upper_bound(make_pair(itc[yy]+dis,1e8));
		for (set<pair<long long,int>/**/>::iterator it=lb;it->first<=itc[yy]+dis;it=r1[mpr[itr[xx]-dis]].lower_bound(make_pair(itc[yy]-dis,0))) 
		{
			if (it->second&&(it->first<=itc[yy]+dis))
			{
				//cerr<<it->second<<endl;
				dfs(it->second);
			}
			else break;
		}
		vlb=lower_bound(btoe(r2[mpr[itr[xx]-dis]]),itc[yy]-dis+1);
		vub=upper_bound(btoe(r2[mpr[itr[xx]-dis]]),itc[yy]+dis);
		ans+=vub-vlb;
		/*for (vector<long long>::iterator it=vlb;it!=vub;it++)
		{
			//cerr<<itr[xx]<<' '<<itc[yy]<<' '<<itr[xx]-dis<<' '<<*it<<endl;
		}*/
	}
	if (mpc.count(itc[yy]-dis))
	{
		lb=c1[mpc[itc[yy]-dis]].lower_bound(make_pair(itr[xx]-dis,0));
		ub=c1[mpc[itc[yy]-dis]].upper_bound(make_pair(itr[xx]+dis,1e8));
		for (set<pair<long long,int>/**/>::iterator it=lb;it->first<=itr[xx]+dis;it=c1[mpc[itc[yy]-dis]].lower_bound(make_pair(itr[xx]-dis,0)))
		{
			if (it->second&&(it->first<=itr[xx]+dis))
			{
				//cerr<<it->second<<endl;
				dfs(it->second);
			}
			else break;
		}
		vlb=lower_bound(btoe(c2[mpc[itc[yy]-dis]]),itr[xx]-dis);
		vub=upper_bound(btoe(c2[mpc[itc[yy]-dis]]),itr[xx]+dis-1);
		ans+=vub-vlb;
		/*for (vector<long long>::iterator it=vlb;it!=vub;it++)
		{
			//cerr<<itr[xx]<<' '<<itc[yy]<<' '<<*it<<' '<<itc[yy]-dis<<endl;
		}*/
	}
	if (mpc.count(itc[yy]+dis))
	{
		lb=c1[mpc[itc[yy]+dis]].lower_bound(make_pair(itr[xx]-dis,0));
		ub=c1[mpc[itc[yy]+dis]].upper_bound(make_pair(itr[xx]+dis,1e8));
		for (set<pair<long long,int>/**/>::iterator it=lb;it->first<=itr[xx]+dis;it=c1[mpc[itc[yy]+dis]].lower_bound(make_pair(itr[xx]-dis,0))) 
		{
			if (it->second&&(it->first<=itr[xx]+dis))
			{
				//cerr<<it->second<<endl;
				dfs(it->second);
			}
			else break;
		}
		vlb=lower_bound(btoe(c2[mpc[itc[yy]+dis]]),itr[xx]-dis+1);
		vub=upper_bound(btoe(c2[mpc[itc[yy]+dis]]),itr[xx]+dis);
		ans+=vub-vlb;
		/*for (vector<long long>::iterator it=vlb;it!=vub;it++)
		{
			//cerr<<itr[xx]<<' '<<itc[yy]<<' '<<*it<<' '<<itc[yy]+dis<<endl;
		}*/
	}
}
int main()
{
	cin>>n>>a>>b;
	for (i=1;i<=n;i++)
	{
		cin>>x>>y;
		dax[i]=x+y;
		day[i]=x-y;
		//row[x+y].insert(make_pair(x-y,i));
		//col[x-y].insert(make_pair(x+y,i));
		//lsx.push_back(dax[i]);
		//lsy.push_back(day[i]);
		if (!mpr[x+y])
		{
			mpr[x+y]=++cntx;
			itr[cntx]=x+y;
			r1[cntx].insert(make_pair(2e15+7,-1));
		}
		if (!mpc[x-y])
		{
			mpc[x-y]=++cnty;
			itc[cnty]=x-y;
			c1[cntx].insert(make_pair(2e15+7,-1));
		}
	}
	/*sort(lsx.begin(),lsx.end());
	unique(lsx.begin(),lsx.end());
	sort(lsy.begin(),lsy.end());
	unique(lsy.begin(),lsy.end());
	for (i=1;i<=n;i++)
	{
		dax[i]=upper_bound(lsx.begin(),lsx.end(),dax[i])-lsx.begin()+2;
		day[i]=upper_bound(lsy.begin(),lsy.end(),day[i])-lsy.begin()+2;
	}*/
	dis=max(abs(dax[a]-dax[b]),abs(day[a]-day[b]));
	//for (i=1;i<=n;i++) cerr<<dax[i]<<' '<<day[i]<<endl; 
	for (i=1;i<=n;i++) dax[i]=mpr[dax[i]];
	for (i=1;i<=n;i++) day[i]=mpc[day[i]];
	for (i=1;i<=n;i++)
	{
		r1[dax[i]].insert(make_pair(itc[day[i]],i));
		c1[day[i]].insert(make_pair(itr[dax[i]],i));
		r2[dax[i]].push_back(itc[day[i]]);
		c2[day[i]].push_back(itr[dax[i]]);
	}
	dfs(a);
//	dfs(b);
	cout<<ans/2;
	return 0;
}