#include <bits/stdc++.h>
using namespace std;
int n, m;
int a[100], b[100], t[100];
int f[100100], g[100100];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i] >> b[i];
    t[i] = i;
  }
  sort(t + 1, t + 1 + n, [](int x, int y) { return a[x] < a[y]; });
  f[0] = 0;
  for (int i = 1; i <= m; ++i) f[i] = 1e9;
  for (int i = 1; i <= n; ++i) {
    int x = a[t[i]];
    int l = max((int)1, x - b[t[i]]);
    int r = min(m, x + b[t[i]]);
    int w = 1e9;
    int cnt = 0;
    for (int j = l; j <= r; ++j) w = min(w, f[j - 1]);
    for (int j = 0; j <= m + 1; ++j) g[j] = 1e9;
    while (true) {
      int k = w + cnt;
      g[l] = min(g[l], k);
      g[r] = min(g[r], k);
      if (l == 1 && r == m) break;
      l = max(int(1), l - 1);
      r = min(m, r + 1);
      w = min(w, min(f[l - 1], f[r - 1]));
      cnt++;
    }
    for (int j = 1; j <= x; ++j) {
      g[j] = min(g[j], g[j - 1]);
      f[j] = min(f[j], g[j]);
    }
    for (int j = m; j >= x; --j) {
      g[j] = min(g[j], g[j + 1]);
      f[j] = min(f[j], g[j]);
    }
  }
  cout << f[m];
}
