#include <bits/stdc++.h>

#define F first
#define S second
#define pii pair<int, int>
#define pb push_back

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = 1e5 + 10;

ll x[N], p[N];
ll ans;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n, S; cin >> n >> S;
	int pos = -1;
	for (int i=0; i<n; i++)
	{
		cin >> x[i] >> p[i];
		if(x[i] < S) pos = i;
	}

	int st = 0, en = n - 1, dir = -1;
	while(true)
	{
		if(st > pos){ ans += x[en] - S; break ;}
		else if(en <= pos){ ans += S - x[st]; break; }
		if(p[st] >= p[en])
		{
			if(dir != 0) ans += x[en] - x[st];
			dir = 0;
			p[st] += p[en];
			en --;
		}else 
		{
			if(dir != 1) ans += x[en] - x[st];
			dir = 1;
			p[en] += p[st];
			st ++;
		}
	}
	cout << ans << endl;
}
#include<bits/stdc++.h>
using namespace std;

const int maxn=100005;

inline int read(){
	register int x=0,w=1,ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')w=-1;
	for(;ch>='0'&&ch<='9';ch=getchar())x=x*10+ch-48;
	return w*x;
}

int n,s,x[maxn];
long long p[maxn];

long long calc(int l,int r,int lst){
	if(s<x[l])return x[r]-s;
	if(x[r]<s)return s-x[l];
	if(p[l]>=p[r]){
		p[l]+=p[r];
		return calc(l,r-1,l)+(lst==r)*(x[r]-x[l]);
	}
	else{
		p[r]+=p[l];
		return calc(l+1,r,r)+(lst==l)*(x[r]-x[l]);
	}
}

int main(){
	n=read(),s=read();
	for(int i=1;i<=n;i++)
		x[i]=read(),p[i]=read();
	cout<<calc(1,n,p[1]<p[n]?1:n)<<'\n';
	return 0;
}