#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int INF = 200000;
const long long INFLL = 1e18;
const int MAX_N = 100000;
int N, M;
vector<pair<int, int> > vt;
bool sf(pair<int, int> a, pair<int, int> b) {
  return a.first - a.second < b.first - b.second;
}
int dp[MAX_N + 1], dp2[MAX_N + 1];
int main() {
  scanf("%d%d", &N, &M);
  for (int i = 0; i < N; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    vt.push_back({a, b});
  }
  sort(vt.begin(), vt.end(), sf);
  dp[0] = dp2[0] = 0;
  for (int i = 1; i <= M; i++) dp[i] = dp2[i] = INF;
  for (int i = 0; i < N; i++) {
    int l = vt[i].first - vt[i].second, r = vt[i].first + vt[i].second;
    for (int j = 0; j < M; j++) {
      if (dp[j] == INF) continue;
      int k = j + 1;
      if (l <= k) {
        dp2[min(M, r)] = min(dp2[min(M, r)], dp[j]);
      } else {
        k = l - k;
        dp2[min(M, r + k)] = min(dp2[min(M, r + k)], dp[j] + k);
      }
    }
    for (int j = r + 1; j <= M; j++) {
      dp2[j] = min(dp2[j], dp2[j - 1] + 1);
    }
    dp[M] = dp2[M];
    for (int j = M - 1; j >= 0; j--) {
      dp2[j] = min(dp2[j], dp2[j + 1]);
      dp[j] = dp2[j];
    }
  }
  printf("%d", dp[M]);
  return 0;
}
