#include<bits/stdc++.h>
using namespace std;
using Int = long long;

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n,s;
  cin>>n>>s;
  vector<Int> x(n),p(n);
  for(Int i=0;i<n;i++) cin>>x[i]>>p[i];
  Int l=0,r=n-1;
  vector<Int> dp(n,0);
  while(x[l]<s&&s<x[r]){
    if(p[l]>=p[r]){
      p[l]+=p[r];
      chmax(dp[l],dp[r]+abs(x[r]-x[l]));
      r--;
    }else{
      p[r]+=p[l];
      chmax(dp[r],dp[l]+abs(x[r]-x[l]));
      l++;
    }
  }
  Int ans=0;
  for(Int i=0;i<n;i++) chmax(ans,dp[i]+abs(s-x[i]));
  cout<<ans<<endl;
  return 0;
}
