#include<bits/stdc++.h>
#define re register
int x[100100];
long long p[101000];
int main()
{
	re int n,s,i1,i2,nw;
	re long long ans=0;
	scanf("%d%d",&n,&s);
	i1=1;i2=n;
	for(re int i=1;i<=n;i++)scanf("%d%lld",&x[i],&p[i]);
	if(x[n]<=s){printf("%d\n",s-x[1]);return 0;}
	else if(x[1]>=s){printf("%d\n",x[n]-s);return 0;}
	if(p[1]>=p[n])nw=1,p[1]+=p[n],i2--;else nw=2,p[n]+=p[1],i1++;
	ans=x[n]-x[1];
	while(1)
	{
		if(x[i1]>=s){printf("%lld\n",ans+x[i2]-s);return 0;}
		if(x[i2]<=s){printf("%lld\n",ans+s-x[i1]);return 0;}
		if(p[i1]>=p[i2])
		{
			if(nw!=1)nw=1,ans+=x[i2]-x[i1];
			p[i1]+=p[i2];i2--;
		}
		else
		{
			if(nw!=2)nw=2,ans+=x[i2]-x[i1];
			p[i2]+=p[i1];i1++;
		}
	}
}