#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
int x[MAXN], wt[MAXN];
int main(int argc, char const *argv[])
{
	int n, s;
	cin>>n>>s;
	for (int i = 0; i < n; ++i)
	{
		cin>>x[i]>>wt[i];
	}
	int lptr = 0, rptr = n - 1;
	long long int early_l = 0, early_r = 0;
	vector <int> A;
	while(lptr < n && x[lptr] < s && rptr >= 0 && x[rptr] > s)
	{
		if(early_l + wt[lptr] >= early_r + wt[rptr])
		{
			early_l+=(early_r + wt[rptr]);
			early_r = 0;
			A.push_back(rptr);
			rptr--;
		}
		else
		{
			early_r+=(early_l + wt[lptr]);
			early_l = 0;
			A.push_back(lptr);
			lptr++;
		}
	}
	while(lptr < n && x[lptr] < s)
	{
		A.push_back(lptr);
		lptr++;
	}
	while(rptr >= 0 && x[rptr] > s)
	{
		A.push_back(rptr);
		rptr--;
	}
	long long int ans = 0;
	for (int i = n - 1; i >= 0; --i)
	{
		ans+=abs(s - x[A[i]]);
		s = x[A[i]];
	}
	cout<<ans<<"\n";
	return 0;
}