#include <bits/stdc++.h>
using namespace std;
int n, m;
pair<int, int> a[85];
vector<pair<int, int> > adj[100005];
int dp[100005];
int tree[4 * 100005];
void update(int v, int l, int r, int pos, int d) {
  if (l > r || l > pos || pos > r) return;
  if (l == r) {
    tree[v] = d;
    return;
  }
  int mid = (l + r) / 2;
  update(2 * v, l, mid, pos, d);
  update(2 * v + 1, mid + 1, r, pos, d);
  tree[v] = min(tree[2 * v], tree[2 * v + 1]);
}
int minnn(int v, int l, int r, int lt, int rt) {
  if (l > r || lt > rt || l > rt || lt > r) return m + 500;
  if (lt <= l && r <= rt) return tree[v];
  int mid = (l + r) / 2;
  return min(minnn(2 * v, l, mid, lt, rt),
             minnn(2 * v + 1, mid + 1, r, lt, rt));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    int x, s;
    cin >> x >> s;
    int maxx = max(x - s - 1, m - (x + s));
    maxx = max(0, maxx);
    for (int j = 0; j <= maxx; j++) {
      int l = max(1, x - s - j) + 1;
      int r = min(m, x + s + j) + 1;
      adj[r].push_back({l - 1, j});
    }
  }
  for (int i = 1; i <= 4 * (m + 1) + 5; i++) tree[i] = m + 500;
  dp[1] = 0;
  update(1, 1, m + 1, 1, 0);
  for (int i = 2; i <= m + 1; i++) {
    dp[i] = m + 500;
    for (auto x : adj[i]) {
      dp[i] = min(dp[i], minnn(1, 1, m + 1, x.first, i - 1) + x.second);
    }
    update(1, 1, m + 1, i, dp[i]);
  }
  cout << dp[m + 1] << " ";
  return 0;
}
