#include <bits/stdc++.h>
using namespace std;
int n, m, l, r, u, x, y;
int dp[100000];
pair<int, int> a[100000];
int b[100000];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie();
  cout.tie();
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> x >> y;
    a[i] = make_pair(x, y);
    b[max(x - y, 0)] += 1;
    b[min(x + y, m)] -= 1;
  }
  for (int i = 1; i <= m; i++) b[i] += b[i - 1];
  dp[m] = 0;
  for (int i = m - 1; i >= 0; i--) {
    dp[i] = m - i;
    if (b[i] > 0) {
      dp[i] = dp[i + 1];
      continue;
    }
    for (int j = 1; j <= n; j++) {
      l = a[j].first - a[j].second;
      if (i >= l) continue;
      r = a[j].first + a[j].second;
      u = l - i - 1;
      dp[i] = min(dp[i], u + dp[min(m, r + u)]);
    }
  }
  cout << dp[0];
}
