#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

Int n, s, res;
Int x[108000], p[108000];

int main(){
  cin >> n >> s;
  for(int i = 0;i < n;i++){
    cin >> x[i] >> p[i];
  }
  int l = 0, r = n-1;
  vector<Int> pos;
  while(x[l] < s && s < x[r]){
    if(p[l] >= p[r]){
      pos.push_back(x[r]);
      p[l] += p[r];
      r--;
    }
    else{
      pos.push_back(x[l]);
      p[r] += p[l];
      l++;
    }
  }
  if(x[r] < s)pos.push_back(x[l]);
  else pos.push_back(x[r]);
  for(int i = pos.size() - 1;i >= 0;i--){
    res += abs(s - pos[i]);
    s = pos[i];
  }
  cout << res << endl;
  return 0;
}