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

int n, s, x[101000];
long long p[101000];

int main(void) {
  scanf("%d%d", &n, &s);
  for(int i = 1; i <= n; i++) {
    scanf("%d%lld", &x[i], &p[i]);
  }
  int l = 1, r = n, flg1 = 1, flg2 = 1;
  long long ans = 0;
  while(l <= r) {
    if(s <= x[l]) {
      ans += x[r] - s;
      break;
    }
    if(s >= x[r]) {
      ans += s - x[l];
      break;
    }
    if(p[l] >= p[r]) {
      p[l] += p[r];
      if(flg1) ans += x[r] - x[l];
      r--;
      flg1 = 0;
      flg2 = 1;
    } else {
      p[r] += p[l];
      if(flg2) ans += x[r] - x[l];
      l++;
      flg2 = 0;
      flg1 = 1;
    }
    //hcerr << l << " " << r << " " << ans << endl;
  }
  printf("%lld\n", ans);
  return 0;
}
