#include <bits/stdc++.h>
using namespace std;
int n, pos, x[100010], id, g[100010], u;
long long s[100010];
long long ans;
int read() {
  int x = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch >= '0' && ch <= '9') {
    x = (x << 3) + (x << 1) + ch - '0';
    ch = getchar();
  }
  return x;
}
void work(int l, int r) {
  if (u <= l) {
    for (int i = r; i >= l; --i) g[id--] = i;
    return;
  }
  if (u >= r + 1) {
    for (int i = l; i <= r; ++i) g[id--] = i;
    return;
  }
  if (s[l] > s[r]) {
    g[id--] = r;
    s[l] += s[r];
    work(l, r - 1);
  } else {
    g[id--] = l;
    s[r] += s[l];
    work(l + 1, r);
  }
}
int main() {
  n = read();
  pos = read();
  for (int i = 1; i <= n; ++i) x[i] = read(), s[i] = read();
  id = n;
  u = lower_bound(x + 1, x + n + 1, pos) - x;
  work(1, n);
  for (int i = 1; i <= n; ++i) ans += abs(x[g[i]] - pos), pos = x[g[i]];
  cout << ans;
  return 0;
}
