#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m;
  cin >> n >> m;
  long long c[n], s[n];
  for (int i = 0; i < n; i++) {
    cin >> c[i] >> s[i];
  }
  long long dp[m + 1];
  dp[m] = 0;
  for (int i = m - 1; i >= 0; i--) {
    dp[i] = m - i;
    for (int j = 0; j < n; j++) {
      long long l = c[j] - s[j];
      l = max(0LL, l);
      long long r = c[j] + s[j];
      r = min(r, m);
      if (i + 1 >= l && i + 1 <= r) {
        dp[i] = min(dp[i], dp[i + 1]);
        break;
      }
      if (i < l) {
        long long gap = l - i - 1;
        long long rr = r + gap;
        rr = min(m, rr);
        dp[i] = min(dp[i], gap + dp[rr]);
      }
    }
  }
  cout << dp[0] << endl;
  return 0;
}
