#include<bits/stdc++.h>
using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;

const int maxn=100005;
int n,s,pos;
int x[maxn];
ll p[maxn],ans;

pll solve(int l,int r){
	if(r<=pos)return mp(s-x[l],s-x[r]);
	if(l>pos)return mp(x[l]-s,x[r]-s);
	if(p[l]>=p[r]){
		p[l]+=p[r];
		pll res=solve(l,r-1);
		return mp(res.fst,res.fst+x[r]-x[l]);
	}
	else{
		p[r]+=p[l];
		pll res=solve(l+1,r);
		return mp(res.snd+x[r]-x[l],res.snd);
	}
}

int main(){
	scanf("%d%d",&n,&s);
	REP(i,n)scanf("%d%lld",&x[i],&p[i]);
	while(pos+1<=n&&x[pos+1]<s)pos++;
	pll ans=solve(1,n);
	printf("%lld\n",max(ans.fst,ans.snd));
	return 0;
}
