#include <bits/stdc++.h>
using namespace std;
const double pai = acos(-1);
const double eps = 1e-8;
const long long mod = 1e9 + 7;
const int MXN = 1e6 + 5;
int x[85], s[85];
int dp[MXN], col[MXN];
int main() {
  int n, m, mi = INT_MAX;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) dp[i] = INT_MAX;
  for (int i = 1; i <= n; i++)
    cin >> x[i] >> s[i], mi = min(mi, x[i] - s[i] - 1);
  for (int i = 1; i <= n; i++)
    for (int j = max(1, x[i] - s[i]); j <= min(m, x[i] + s[i]); j++) col[j] = 1;
  for (int i = 1; i <= mi; i++) dp[i] = i;
  dp[0] = 0;
  for (int i = max(1, mi + 1); i <= m; i++) {
    if (col[i]) {
      dp[i] = dp[i - 1];
      continue;
    }
    for (int j = 1; j <= n; j++) {
      if (i > x[j] + s[j])
        dp[i] = min(dp[i], dp[i - 2 * (i - x[j]) - 1] + i - x[j] - s[j]);
    }
  }
  cout << dp[m] << '\n';
  return 0;
}
