#include <bits/stdc++.h>
using namespace std;
const int64_t N = 2e5 + 5;
const int64_t INF = 1e18 + 7;
const int64_t MOD = 1e9 + 7;
int64_t n, m;
int64_t dp[N];
bool good[N];
vector<pair<int64_t, int64_t>> v;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int64_t i = 0; i < n; i++) {
    int64_t a, b;
    cin >> a >> b;
    for (int64_t j = max((int64_t)1, a - b); j <= min(m, a + b); j++)
      good[j] = true;
    v.push_back({a, b});
  }
  for (int64_t i = 1; i <= m; i++) dp[i] = dp[i - 1] + (!good[i]);
  for (int64_t i = 0; i <= m; i++) {
    if (good[i]) dp[i] = min(dp[i], dp[i - 1]);
    for (auto x : v) {
      int64_t len = x.first - i - 1;
      int64_t cost = max((int64_t)0, len - x.second);
      int64_t pos = min(m, (int64_t)len + x.first);
      pos = max((int64_t)0, pos);
      dp[pos] = min(dp[pos], dp[i] + cost);
    }
  }
  int64_t ans = m;
  for (int64_t i = 0; i <= m; i++) ans = min(ans, dp[i] + m - i);
  cout << ans << endl;
}
