#include<cstdio>
#include<cstring>
#include<cstring>
#include<algorithm>
#include<vector>
#define maxn 100005
#define ll long long
using namespace std;

int n,i,j,k;
ll ans,c[maxn],x[maxn],now;

ll dg(int l,int r){
	ll s;
	if (x[l]>=now) {s=x[r]-now,now=x[r];return s;}
	if (x[r]<=now) {s=now-x[l],now=x[l];return s;}
	if (c[l]>=c[r]) 
		c[l]+=c[r],s=dg(l,r-1),s+=x[r]-now,now=x[r];
	else c[r]+=c[l],s=dg(l+1,r),s+=now-x[l],now=x[l];
	return s;
}

int main(){
	scanf("%d%lld",&n,&now);
	for(i=1;i<=n;i++) scanf("%lld%lld",&x[i],&c[i]);
	printf("%lld",dg(1,n));
}