#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

typedef long long ll;
const int maxn = 1e5 + 10 , oo = 1e9 + 7;
int n , s;
int x[maxn];
ll p[maxn];
int main(){
	ios::sync_with_stdio(0);
	cin >> n >> s;
	for(int i = 1 ; i <= n ; ++ i)
		cin >> x[i] >> p[i];
	x[n + 1] = oo;
	int mid;
	for(int i = 0 ; i <= n ; ++ i)
		if(x[i] < s && x[i + 1] > s){
			mid = i;
			break;
		}
	ll ans = 0;
	int l = 1 , r = n;
	int last = -1;
	while(l <= mid && r > mid){
		if(p[l] < p[r]){
			if(last != 0){
				ans += x[r] - x[l];
				last = 0;
			}
			p[r] += p[l];
			l ++;
		}
		else{
			if(last != 1){
				ans += x[r] - x[l];
				last = 1;
			}
			p[l] += p[r];
			r --;
		}
	}
	if(l <= mid)
		ans += s - x[l];
	if(r > mid)
		ans += x[r] - s;
	cout << ans << endl;
	return 0;
}