#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5;
int n,s,l,r;
ll x[N],p[N],ans;
int main()
{
	scanf("%d%d",&n,&s);
	for (int i=1;i<=n;i++) scanf("%lld%lld",&x[i],&p[i]);
	l=1;r=n;
	while (1==1)
	{
		if (x[r]<=s) {ans+=s-x[l];break;}
		if (x[l]>=s) {ans+=x[r]-s;break;}
		if (p[l]>=p[r])
		{
			ans+=x[r]-x[l];
			while (l<r&&p[l]>=p[r]) p[l]+=p[r--];//注意l<r,不能取等 
		}else {
			ans+=x[r]-x[l];
			while (l<r&&p[l]<p[r]) p[r]+=p[l++];
		}
	}
	printf("%lld\n",ans);
	return 0;
}