#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n, S, X[N];
long long P[N];
int main() {
	scanf("%d%d", &n, &S);
	for (int i = 1; i <= n; i++) {
		scanf("%d%lld", &X[i], &P[i]);
	}
	long long ans = 0;
	int lastd = 0, L = 1, R = n;
	while (true) {
		if (X[L] >= S) {
			ans += X[R] - S;
			break;
		}
		if (X[R] <= S) {
			ans += S - X[L];
			break;
		}
		if (P[L] >= P[R]) {
			if (lastd != 1) {
				lastd = 1;
				ans += X[R] - X[L];
			}
			P[L] += P[R];
			R--;
		} else {
			if (lastd != 2) {
				lastd = 2;
				ans += X[R] - X[L];
			}
			P[R] += P[L];
			L++;
		}
	}
	printf("%lld\n", ans);
	return 0;
}