#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 50;
pair<int, int> a[N];
int n, dp[N], m;
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  for (int x, s, i = 1; i <= n; i++)
    cin >> x >> s, a[i] = make_pair(max(0, x - s), min(m, x + s));
  memset(dp, 0x7f, sizeof(dp));
  dp[m] = 0;
  for (int i = m - 1; i >= 0; i--) {
    dp[i] = m - i;
    for (int j = 1; j <= n; j++) {
      int l = a[j].first, r = a[j].second;
      if (l <= i + 1 and i + 1 <= r) {
        dp[i] = dp[i + 1];
        break;
      }
      if (i < l) {
        dp[i] = min(dp[i], dp[min(m, r + l - i - 1)] + l - i - 1);
      }
    }
  }
  cout << dp[0] << endl;
}
