#include <bits/stdc++.h>
using namespace std;
vector<string> vec_splitter(string s) {
  for (char& c : s) c = c == ',' ? ' ' : c;
  stringstream ss;
  ss << s;
  vector<string> res;
  for (string z; ss >> z; res.push_back(z))
    ;
  return res;
}
void debug_out(vector<string> args, int idx) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, Head H, Tail... T) {
  if (idx > 0) cerr << ", ";
  stringstream ss;
  ss << H;
  cerr << args[idx] << " = " << ss.str();
  debug_out(args, idx + 1, T...);
}
void localTest() {}
const long long N = 85, M = 1e5 + 5;
long long L[N], R[N], dp[M];
int main() {
  localTest();
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, m;
  cin >> n >> m;
  for (long long i = 1; i <= n; ++i) {
    long long x, s;
    cin >> x >> s;
    L[i] = max(0LL, x - s);
    R[i] = min(m, x + s);
  }
  for (long long i = m - 1; i >= 0; --i) {
    dp[i] = m - i;
    for (long long j = 1; j <= n; ++j) {
      if (L[j] <= i + 1 && i + 1 <= R[j]) {
        dp[i] = dp[i + 1];
        break;
      }
      if (i < L[j]) {
        long long cost = L[j] - i - 1;
        long long nxt = min(m, R[j] + cost);
        dp[i] = min(dp[i], dp[nxt] + cost);
      }
    }
  }
  cout << dp[0] << "\n";
  return 0;
}
