// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
// #include<deque>
// #include<multiset>
// #include<bitset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

// #undef DEBUG
// #define DEBUG
// DEBUG {{{
#include <array>
#include <deque>
#include <iostream>
#include <list>
#include <queue>
#include <stack>
#include <tuple>
#include <valarray>
#include <vector>
// clang-format off
template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, tuple<T...> const &){}
template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream & os, tuple<T...> const & t){ os << (n==0?"":", ") << get<n>(t); _ot<n+1>(os, t); }
template<class...T> ostream & operator<<(ostream &o, tuple<T...> const &t){ o << "("; _ot<0>(o, t); o << ")"; return o; }
template<class T, class U> ostream & operator<<(ostream &o, pair<T, U> const &p) { o << "(" << p.first << ", " << p.second << ")"; return o; }
template < class T > ostream &operator<<(ostream &o, const stack<T> &a) { o << "{"; for(auto tmp = a; tmp.size(); tmp.pop()) o << (a.size() == tmp.size() ? "" : ", ") << tmp.top(); o << "}"; return o; }
template <class T, class Container, class Compare > ostream &operator<<(ostream &os, priority_queue<T, Container, Compare> a) { os << "{ (top) "; while(a.size()) os << a.top() << (a.size() == 1 ? "" : ", "), a.pop(); os << " }"; return os; }
template <class T, class Container > ostream &operator<<(ostream &os, queue<T, Container> a) { os << "{ "; while(a.size()) os << a.front() << (a.size() == 1 ? "" : ", "), a.pop(); os << " }"; return os; }
#ifdef DEBUG
#if !defined(DEBUG_OUT)
// #define DEBUG_OUT cerr
#endif
#if !defined(DEBUG_LEFT)
// #define DEBUG_LEFT "\e[1;36m"
#endif
#if !defined(DEBUG_RIGHT)
// #define DEBUG_RIGHT ":\e[m"
#endif
#define dump(...) [&](){auto __debug_tap=make_tuple(__VA_ARGS__);DEBUG_OUT<<DEBUG_LEFT<<__LINE__ << DEBUG_RIGHT << " " <<#__VA_ARGS__<<" = "<<__debug_tap<<endl;}()
template < class T > inline void dump2D(T &d, size_t sizey, size_t sizex) { for(size_t i = 0; i < sizey; i++) { DEBUG_OUT << "\t"; for(size_t j = 0; j < sizex; j++) DEBUG_OUT << d[i][j] << (j + 1 == sizex ? "" : "\t"); DEBUG_OUT << endl; } }
template < class T > inline void dump1D(T &d, size_t sizey) { for(size_t i = 0; i < sizey; i++) { DEBUG_OUT << d[i] << (i + 1 == sizey ? "" : " "); } DEBUG_OUT << endl; }
template < class T, class = typename iterator_traits< decltype(begin(T())) >::value_type, class = typename enable_if<!is_same<T, string>::value>::type > ostream &operator<<(ostream &o, const T &a) { o << "{"; for(auto ite = begin(a); ite != end(a); ++ite) o << (ite == begin(a) ? "" : ", ") << *ite; o << "}"; return o; }
#else
#define dump(...) (42)
#define dump2D(...) (42)
#define dump1D(...) (42)
template < class T, class = typename iterator_traits< decltype(begin(T())) >::value_type, class = typename enable_if<!is_same<T, string>::value>::type > ostream &operator<<(ostream &o, const T &a) { for(auto ite = begin(a); ite != end(a); ++ite) o << (ite == begin(a) ? "" : " ") << *ite; return o; }
#endif
// clang-format on
// }}}


const int N = 1e5;
ll x[N], p[N], rv[N];
ll psum[N];
ll rvsum[N];

// accum1D, range1D, range1Dloop {{{
#include <vector>
template < class T >
void accum1D(T &a, int n) {
  for(int i = 1; i < n; i++) a[i] += a[i - 1];
}
template < class T >
void accum1D(vector< T > &a) {
  accum1D(a, a.size());
}
template < class T, int N >
void accum1D(T a[N]) {
  accum1D(a, N);
}

template < class T >
auto range1D(const T &a, int l, int r, int n) {
  if(r >= n) r = n - 1;
  auto res(a[r]);
  if(l - 1 >= 0) res -= a[l - 1];
  return res;
}
template < class T >
auto range1D(vector< T > &a, int l, int r) {
  return range1D(a, l, r, a.size());
}
template < class T, int N >
auto range1D(T a[N], int l, int r) {
  return range1D(a, l, r, N);
}

template < class T >
auto range1Dloop(const T &a, ll tl, ll r, int n) {
  decltype(a[0]) res(0);
  if(tl > r) return res;
  assert(n >= 1);
  ll l = tl % n;
  if(l < 0) l += n;
  r += l - tl;
  ll gr = r / n;
  if(gr == 0) {
    res += range1D< T >(a, l, r, n);
  } else {
    res += range1D< T >(a, l, n - 1, n);
    res += range1D< T >(a, 0, r % n, n);
    res += range1D< T >(a, 0, n - 1, n) * (gr - 1);
  }
  return res;
}
template < class T >
T range1Dloop(vector< T > &a, ll l, ll r) {
  return range1Dloop(a, l, r, a.size());
}
template < class T, int N >
T range1Dloop(T a[N], ll l, ll r) {
  return range1Dloop(a, l, r, N);
}
// }}}

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int n, s;
  ll ans = 0;
  cin >> n >> s;
  int L = 0, R = n - 1;
  int m = 0;
  for(int i = 0; i < n; i++) {
    cin >> x[i] >> p[i];
    if(x[i] < s) m = i + 1;
  }

  int last = 2;
  while(L < R && L < m && m <= R) {
    if(p[L] >= p[R]) {
      p[L] += p[R];
      if(last != 0) ans += x[R] - x[L];
      last = 0;
      R--;
    } else {
      p[R] += p[L];
      if(last != 1) ans += x[R] - x[L];
      last = 1;
      L++;
    }
  }
  if(R < m) {
    if(last != 1) ans += s - x[L];
  } else if(m <= L) {
    if(last != 0) ans += x[R] - s;
  } else assert(0);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792