#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;

typedef long long ll;
const int MAXN = 1e5 + 10;
int N, S;
int X[MAXN]; ll P[MAXN];
ll ans;

int main() {
	register int i;
	scanf("%d%d", &N, &S);
	for(i = 1; i <= N; ++i)
		scanf("%d%lld", X + i, P + i);
	int l = 1, r = N, las = 0;
	while(X[l] <= S && S <= X[r]) {
		if(P[l] >= P[r]) P[l] += P[r], ans += (X[r--] - X[l]) * (las != 1), las = 1;
		else P[r] += P[l], ans += (X[r] - X[l++]) * (las != 2), las = 2;
	}
	if(l <= r) {
		if(X[l] <= S) ans += S - X[l];
		else ans += X[r] - S;
	}
	printf("%lld\n", ans);
	return 0;
}