#include<bits/stdc++.h>
using namespace std;
const int N=300005;
int n,s,x[N];
long long z,p[N];
int main()
{
	scanf("%d%d",&n,&s);
	for (int i=1;i<=n;i++)scanf("%d%d",&x[i],&p[i]);
	for (int l=1,r=n;l<=r;)
	 {
	 	if (x[l]>=s)
	 	 {
	 	 	z+=x[r]-s;
	 	 	break;
		 }
		if (x[r]<=s)
		 {
		 	z+=s-x[l];
		 	break;
		 } 
		z+=x[r]-x[l];
		if (p[l]>=p[r])
		 {while (l<r&&p[l]>=p[r])p[l]+=p[r--];}
		else {while (l<r&&p[l]<p[r])p[r]+=p[l++];}  
	 }
	printf("%lld",z);
	return 0;
}