#include<bits/stdc++.h>
using namespace std;
long long x[100010],p[100010];
int main()
{	int n,s,l=1,r;long long ans=0;cin>>n>>s;r=n;
	for(int i=1;i<=r;i++) cin>>x[i]>>p[i];
	while(l<=r)
	{	if(s<=x[l]) cout<<ans+x[r]-s,exit(0);
		if(s>=x[r]) cout<<ans+s-x[l],exit(0);
		ans+=x[r]-x[l];
		if(p[l]>=p[r]) while(p[l]>=p[r]&&l<r) p[l]+=p[r--];
		else while(p[l]<p[r]&&l<r) p[r]+=p[l++];
	}
}
