#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
const long double eps = 1e-9;
const int seed = 131;
const int M = 1e5 + 7;
int x[100], s[100];
int f[M], col[M];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  int mi = m + 1;
  for (int i = 1; i <= n; i++) cin >> x[i] >> s[i], mi = min(mi, x[i] - s[i]);
  for (int i = 1; i <= n; i++)
    for (int j = max(0, x[i] - s[i]); j <= min(m, x[i] + s[i]); j++) col[j] = 1;
  for (int i = 1; i <= mi; i++) f[i] = i;
  for (int i = max(1, mi); i <= m; i++) {
    if (col[i]) {
      f[i] = f[i - 1];
      continue;
    }
    f[i] = 1e9;
    for (int j = 1; j <= n; j++) {
      if (x[j] + s[j] < i) {
        f[i] = min(f[i], f[max(0, i - 2 * (i - x[j]) - 1)] + i - x[j] - s[j]);
      }
    }
  }
  cout << f[m] << endl;
  return 0;
}
