// This amazing code is by Eric Sunli Chen.
#include<bits/stdc++.h>
using namespace std;
template<typename T> bool get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'&&t!=EOF; t=getchar());
	if(t=='-')neg=true,t=getchar();if(t==EOF)return false;
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;return true;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) (get1(a)&&get1(b))
#define get3(a,b,c) (get1(a)&&get2(b,c))
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

const int maxn=100111;
int n,s,x[maxn];
LL p[maxn],ans;

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

int main()
{
	get2(n,s);
	for(int i=1;i<=n;i++)get2(x[i],p[i]);
	calc(1,n);
	printendl(ans);
	return 0;
}
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
vector<int> v;
int main() {
	int n; ll s; cin >> n >> s;
	ll x[100000]; ll p[100000];
	rep(i, n) {
		cin >> x[i] >> p[i];
	}
	int j, k; j = 0; k = n - 1;
	while (j < k) {
		if (p[j] < p[k]) {
			p[k] += p[j];
			if (s > x[j]) {
				v.push_back(j);
			}
			j++;
		}
		else if (p[j] >= p[k]) {
			p[j] += p[k];
			if (s < x[k]) {
				v.push_back(k);
			}
			k--;
		}
	}
	v.push_back(j);
	int len = v.size();
	ll sum = 0; ll now = s;
	per(i, len) {
		sum += abs(x[v[i]] - now);
		now = x[v[i]];
	}
	cout << sum << endl;
	return 0;
}