#include <bits/stdc++.h>
using namespace std;
void test_case() {
  int a, b;
  cin >> a >> b;
  vector<pair<int, int> > t(a);
  for (auto &x : t) cin >> x.first >> x.second;
  vector<int> dp(b + 1);
  vector<bool> covered(b + 1);
  for (int i = 0; i < a; i++) {
    for (int j = max(1, t[i].first - t[i].second);
         j <= min(b, t[i].first + t[i].second); j++) {
      covered[j] = 1;
    }
  }
  for (int i = b; i >= 0; i--) {
    dp[i] = i == b ? 0 : covered[i + 1] ? dp[i + 1] : b - i;
    for (int j = 0; j < a; j++) {
      if (t[j].first - t[j].second > i) {
        int dist = t[j].first - t[j].second - i - 1;
        dp[i] = min(dp[i], dist + dp[min(b, t[j].first + t[j].second + dist)]);
      }
    }
  }
  cout << dp[0];
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t = 1;
  while (t--) {
    test_case();
  }
}
