#include <bits/stdc++.h>

typedef long long ll;
const int N = 100054;

int n, cnt = 0;
int x[N], a[N];
ll p[N];

int main() {
	int i, j, s = 0, v = 0; ll ans = 0;
	scanf("%d%d", &n, x);
	for (i = 1; i <= n; ++i) scanf("%d%lld", x + i, p + i), (x[i] -= *x) < 0 && (s = i); *x = 0;
	for (i = 1, j = n; i <= s && j > s; a[cnt++] = p[i] >= p[j] ? (p[i] += p[j], j--) : (p[j] += p[i], i++));
	for (a[cnt++] = (i <= s ? i : j); cnt; ans += abs(x[ a[--cnt] ] - x[v]), v = a[cnt]);
	printf("%lld\n", ans);
	return 0;
}