#include <bits/stdc++.h>
using namespace std;
int n, m, a[1000100], l[1000100], r[1000100], dp[1000100];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    int x, s;
    cin >> x >> s;
    l[i] = x - s;
    r[i] = x + s;
    for (int j = l[i]; j <= r[i]; j++) {
      a[j] = 1;
    }
  }
  for (int i = m; i > 0; i--) {
    if (a[i]) {
      dp[i] = dp[i + 1];
      continue;
    }
    dp[i] = dp[i + 1] + 1;
    for (int j = 0; j < n; j++) {
      if (l[j] > i) {
        int s = l[j] - i;
        dp[i] = min(dp[i], s + dp[r[j] + s + 1]);
      }
    }
  }
  if (a[1] == 0) {
    int ans = 1000100;
    for (int i = 0; i < n; i++) {
      int s = l[i] - 1;
      ans = min(ans, l[i] - 1 + dp[r[i] + s + 1]);
    }
    cout << ans;
  } else {
    cout << dp[1];
  }
}
