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

const int MAXN = 1e5+5;

ll n, s, x[MAXN], p[MAXN], k;
vector<ll> v;

int main() {
	cin >> n >> s;
	for (int i = 0; i < n; ++i)
		cin >> x[i] >> p[i];
	k = -1;
	for (int i = 0; i < n; ++i)
		if (x[i] < s)
			k++;
	int l = 0, r = n-1;
	while (true) {
		if (k < l) {
			for (int i = r; i >= l; --i)
				v.push_back(i);
			break;
		} if (k >= r) {
			for (int i = l; i <= r; i++)
				v.push_back(i);
			break;
		}
		if (p[l] >= p[r]) {
			v.push_back(r);
			p[l] += p[r];
			r--;
		} else {
			v.push_back(l);
			p[r] += p[l];
			l++;
		}
	}

	ll pos = s;
	reverse(v.begin(), v.end());
	ll ans = 0;
	for (int i = 0; i < v.size(); ++i) {
		ans += abs(x[v[i]] - pos);
		pos = x[v[i]];
	}

	cout << ans << endl;
}