#include <bits/stdc++.h>
using namespace std;
const int maxn = 81, maxm = 1e5 + 1;
int n, m, dp[maxn][maxm];
struct A {
  int x, s;
  int l() { return max(1, x - s); }
  int r() { return x + s; }
  A operator+(int x) {
    A ret = *this;
    ret.s += x;
    return ret;
  }
} a[maxn];
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> a[i].x >> a[i].s;
  sort(a, a + n, [](A a, A b) { return a.x < b.x; });
  memset(dp[0], 63, sizeof dp[0]);
  dp[0][0] = 0;
  for (int i = 0; i < n; i++) {
    memcpy(dp[i + 1], dp[i], sizeof dp[i]);
    for (int x = 0; x <= m; x++) {
      int cost = max(0, x - a[i].r());
      dp[i + 1][x] = min({dp[i + 1][x], cost + dp[i][(a[i] + cost).l() - 1],
                          max(cost, a[i].l() - 1)});
    }
  }
  cout << dp[n][m] << '\n';
}
