#include<iostream>
#include<algorithm>
using namespace std;

int const MAX = 100005;
long long p[MAX], x[MAX];
int order[MAX];

int main() {
	int n, s;
	cin >> n >> s;
	int t = 1; //sを挟んだ境界
	for (int i = 1; i <= n; i++) {
		cin >> x[i] >> p[i];
		if (x[i] < s) {
			t = i + 1;
		}
	}
	int left = 1; int right = n; int now = 1;
	while (left < t && right >= t) {
		if (p[left] >= p[right]) {
			order[now] = right;
			p[left] += p[right];
			right--;
			now++;
		}
		else {
			order[now] = left;
			p[right] += p[left];
			left++;
			now++;
		}
	}
	if (left == t) {
		order[now] = right;
	}
	else if (right < t) {
		order[now] = left;
	}
	for (int i = 1; i <= now; i++) {
	}
	long long ans = abs(s-x[order[now]]);
	while (now>1) {
		ans += abs(x[order[now]] - x[order[now-1]]);
		now--;
	}

	cout << ans << endl;
}