#include <bits/stdc++.h>
using namespace std;
const int maxnn = 1e5 + 7;
const int inf = 0x3f3f3f;
int n, m;
struct dy {
  int x, s;
  int l, r;
} a[maxnn];
bool cmp(dy p, dy q) {
  if (p.l == q.l) return p.r < q.r;
  return p.l < q.l;
}
int dp[maxnn];
int main() {
  scanf("%d %d", &n, &m);
  int rrr = 0;
  int lll = inf;
  for (int i = 0; i <= m; i++) dp[i] = inf;
  for (int i = 1; i <= n; i++) {
    scanf("%d %d", &a[i].x, &a[i].s);
    a[i].l = max(a[i].x - a[i].s, 1);
    a[i].r = min(a[i].x + a[i].s, m);
    lll = min(lll, a[i].l);
    rrr = max(rrr, a[i].r);
    for (int j = a[i].l; j <= a[i].r; j++) {
      dp[j] = 0;
    }
  }
  for (int i = 1; i < lll; i++) {
  }
  for (int i = rrr + 1; i <= m; i++) {
    dp[i] = m - i + 1;
  }
  sort(a + 1, a + n + 1, cmp);
  dp[m + 1] = 0;
  for (int i = m; i >= 1; i--) {
    if (dp[i] == 0) dp[i] = dp[i + 1];
    for (int j = 1; j <= n; j++) {
      if (a[j].l > i) {
        int dis = a[j].l - i;
        int R = min(a[j].r + dis, m);
        dp[i] = min(dp[i], dp[R + 1] + dis);
      }
    }
  }
  printf("%d\n", dp[1]);
  return 0;
}
