#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,s,x[100010],p[100010];
long long nowl,nowr,suml[100010],sumr[100010],ans,pos[100010];
int main()
{
	scanf("%d %d",&n,&s);
	for(int i=1;i<=n;++i)scanf("%d %d",&x[i],&p[i]);
//	for(int i=1;i<=n;++i)suml[i]=suml[i-1]+p[i];
//	for(int i=n;i;--i)sumr[i]=sumr[i+1]+p[i];
	int ls,rs,l,r;
	for(int i=1;i<=n;++i)if(x[i]<s)ls=i;
	rs=ls+1;
	l=1,r=n;
	int last=-1;
	while(l<=ls&&r>=rs)
	{
		if(p[l]+nowl>=p[r]+nowr)
		{
			if(last!=1)ans+=x[r]-x[l];
			last=1;
		//	pos[r]=l-1;
			nowl+=p[r];
			nowl+=nowr,nowr=0;
			--r;
		}
		else
		{
			if(last!=2)ans+=x[r]-x[l];
			last=2;
		//	pos[l]=r+1;
			nowr+=p[l];
			nowr+=nowl,nowl=0;
			++l;
		}
	//	printf("%d %d %lld\n",l,r,ans);
	}
	if(l>ls)ans+=x[r]-s;
	else ans+=s-x[l];
	printf("%lld",ans);
	return 0;
}
