#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> m >> n;
  vector<pair<int, int> > a(m);
  for (int i = 0; i < m; ++i) {
    cin >> a[i].first >> a[i].second;
    --a[i].first;
  }
  sort((a).begin(), (a).end());
  vector<vector<int> > dp(n + 1, vector<int>(m + 5, (int)1e9));
  for (int i = 0; i < m; ++i) dp[0][i] = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (dp[i][j] == (int)1e9) continue;
      int up = (a[j].first > i ? max(0, (a[j].first - a[j].second) - i)
                               : max(0, i - (a[j].first + a[j].second)));
      if (a[j].first + a[j].second + up + 1 < n)
        dp[min(n - 1, a[j].first + a[j].second + up + 1)][j] =
            min(dp[min(n - 1, a[j].first + a[j].second + up + 1)][j], dp[i][j]);
      for (int to = j + 1; to <= m; ++to) {
        dp[min(n, a[j].first + a[j].second + up + 1)][to] = min(
            dp[min(n, a[j].first + a[j].second + up + 1)][to], dp[i][j] + up);
      }
    }
  }
  int ans = (int)1e9;
  for (int j = 0; j <= m; ++j) {
    ans = min(ans, dp[n][j]);
  }
  cout << ans << "\n";
}
