#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char *s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
const int N = 1e5 + 5;
const int inf = 1e9 + 5;
int dp[85][N];
int x[N], s[N];
int pmx[N];
int n, m;
int main(int argc, char const *argv[]) {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cin.exceptions(cin.failbit);
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    cin >> x[i] >> s[i];
  }
  vi p(n);
  iota(begin(p), end(p), 1);
  sort(begin(p), end(p), [](int i, int j) {
    return ii(x[i] + s[i], s[i] - x[i]) < ii(x[j] + s[j], s[j] - x[j]);
  });
  42;
  fill(dp[0] + 1, dp[0] + N, inf);
  for (int i = 1; i <= n; ++i) {
    int xi = x[p[i - 1]], si = s[p[i - 1]];
    fill(dp[i] + 1, dp[i] + N, inf);
    pmx[0] = dp[i - 1][0];
    for (int j = 1; j <= m; ++j) {
      pmx[j] = min(pmx[j - 1], dp[i - 1][j - 1] - j);
    }
    for (int j = 1; j <= m; ++j) {
      int atleast = max(0, j - (xi + si));
      if (i == 2 and j == m) 42;
      if (xi - si - atleast <= 1) {
        dp[i][j] = min(dp[i - 1][j], atleast);
      } else {
        if (xi - si - atleast > j) {
          dp[i][j] = min(dp[i - 1][j], xi - si + pmx[j]);
        } else {
          dp[i][j] = min(dp[i - 1][j], xi - si + pmx[xi - si - atleast]);
        }
      }
    }
  }
  42;
  cout << dp[n][m] << endl;
  return 0;
}
