#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10, M = 1010, inf = 0x3f3f3f3f, mod = 1e9 + 7;
int n, m;
int l[N], r[N], f[N];
int main() {
  cin >> n >> m;
  for (register int i = 1; i <= n; ++i) {
    int x, s;
    scanf("%d", &x), scanf("%d", &s);
    l[i] = max(1, x - s);
    r[i] = min(m, x + s);
  }
  for (int i = 1; i <= m; i++) f[i] = m - i + 1;
  for (int i = m; i >= 1; i--) {
    for (int j = 1; j <= n; j++) {
      if (i >= l[j] && i <= r[j]) {
        f[i] = min(f[i], f[i + 1]);
      } else if (l[j] > i) {
        f[i] = min(f[i], f[min(r[j] + l[j] - i, m) + 1] + l[j] - i);
      }
    }
  }
  cout << f[1] << endl;
  return 0;
}
