#include <bits/stdc++.h>
using namespace std;
int n, m;
int dp[100005];
int main() {
  std::ios_base::sync_with_stdio(false);
  cin >> n >> m;
  vector<pair<int, int> > dots(n);
  for (int i = 0; i < n; i++) {
    cin >> dots[i].first >> dots[i].second;
  }
  for (int i = 1; i <= m; i++) dp[i] = 1000000;
  dp[0] = 0;
  for (int l = 1; l <= m; l++) {
    for (int i = 0; i < n; i++) {
      int left = dots[i].first - dots[i].second;
      int right = dots[i].first + dots[i].second;
      if (left <= l && right >= l) dp[l] = 0;
    }
  }
  for (int l = 1; l <= m; l++) {
    if (dp[l] == 0) {
      dp[l] = dp[l - 1];
      continue;
    }
    for (int i = 0; i < n; i++) {
      int left = dots[i].first - dots[i].second;
      int right = dots[i].first + dots[i].second;
      if (right < l) {
        if (left - l + right - 1 >= 0)
          dp[l] = min(dp[l], l - right + dp[left - l + right - 1]);
        else
          dp[l] = min(dp[l], l - right);
      }
      dp[l] = min(dp[l], max(left - 1, l - right));
    }
  }
  cout << dp[m];
  return 0;
}
