#include <bits/stdc++.h>
using namespace std;
int n, s, x[100010], p[100010];
long long nowl, nowr, suml[100010], sumr[100010], ans, pos[100010];
int main() {
  scanf("%d %d", &n, &s);
  for (int i = 1; i <= n; ++i) scanf("%d %d", &x[i], &p[i]);
  int ls, rs, l, r;
  for (int i = 1; i <= n; ++i)
    if (x[i] < s) ls = i;
  rs = ls + 1;
  l = 1, r = n;
  int last = -1;
  while (l <= ls && r >= rs) {
    if (p[l] + nowl >= p[r] + nowr) {
      if (last != 1) ans += x[r] - x[l];
      last = 1;
      nowl += p[r];
      nowl += nowr, nowr = 0;
      --r;
    } else {
      if (last != 2) ans += x[r] - x[l];
      last = 2;
      nowr += p[l];
      nowr += nowl, nowl = 0;
      ++l;
    }
  }
  if (l > ls)
    ans += x[r] - s;
  else
    ans += s - x[l];
  printf("%lld", ans);
  return 0;
}
