#include <bits/stdc++.h>
using namespace std;
int dp[85][100010];
pair<int, int> a[100010];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> a[i].first >> a[i].second;
  sort(a + 1, a + n + 1);
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= m; j++) dp[i][j] = 1e9;
  dp[0][0] = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= m; j++) dp[i][j] = dp[i - 1][j];
    for (int j = 0; j <= m; j++) {
      int cost = max(max(a[i].first - j - 1, j - a[i].first), a[i].second) -
                 a[i].second;
      int l = max(0, a[i].first - a[i].second - cost - 1),
          r = min(m, a[i].first + a[i].second + cost);
      dp[i][r] = min(dp[i][r], dp[i - 1][l] + cost);
    }
    for (int j = m - 1; j >= 0; j--) dp[i][j] = min(dp[i][j], dp[i][j + 1]);
  }
  cout << dp[n][m];
  return 0;
}
