#include <bits/stdc++.h>
using namespace std;
void build(long long int tree[], long long int a[], long long int start,
           long long int end, long long int node) {
  if (start > end) return;
  if (start == end) {
    tree[node] = a[start];
    return;
  }
  long long int mid = (start + end) >> 1;
  build(tree, a, start, mid, 2 * node);
  build(tree, a, mid + 1, end, 2 * node + 1);
  tree[node] = min(tree[2 * node], tree[2 * node + 1]);
}
void update(long long int tree[], long long int start, long long int end,
            long long int i, long long int x, long long int node) {
  if (start > end || start > i || end < i) return;
  if (start == end && start == i) {
    tree[node] = min(x, tree[node]);
    return;
  }
  long long int mid = (start + end) >> 1;
  update(tree, start, mid, i, x, 2 * node);
  update(tree, mid + 1, end, i, x, 2 * node + 1);
  tree[node] = min(tree[2 * node], tree[2 * node + 1]);
}
long long int query(long long int tree[], long long int start,
                    long long int end, long long int l, long long int r,
                    long long int node) {
  if (start > end || l > r || start > r || end < l) return 1e10;
  if (l <= start && r >= end) {
    return tree[node];
  }
  long long int mid = (start + end) >> 1;
  return min(query(tree, start, mid, l, r, 2 * node),
             query(tree, mid + 1, end, l, r, 2 * node + 1));
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t = 1;
  while (t--) {
    long long int n, m, ans = 0, x, y;
    cin >> n >> m;
    pair<long long int, long long int> a[n];
    for (int i = 0; i < n; i++) cin >> a[i].first >> a[i].second;
    long long int dp[m + 2][n];
    dp[0][0] = 0;
    for (int i = 1; i <= m; i++) {
      for (int j = 0; j < n; j++) {
        dp[i][j] = 1e10;
        long long int l = max(1ll, a[j].first - a[j].second);
        long long int r = min(m * 1ll, a[j].first + a[j].second);
        if (l <= i && i <= r) {
          for (int k = 0; k < n; k++) dp[i][j] = min(dp[l - 1][k], dp[i][j]);
        } else {
          if (l > i) {
            for (int k = 0; k < n; k++)
              dp[i][j] = min(dp[i - 1][k] + 1, dp[i][j]);
          } else {
            l = max(1ll, l - i + r);
            for (int k = 0; k < n; k++)
              dp[i][j] = min(dp[l - 1][k] + i - r, dp[i][j]);
          }
        }
      }
    }
    ans = 1e10;
    for (int i = 0; i < n; i++) ans = min(dp[m][i], ans);
    cout << ans << "\n";
  }
  return 0;
}
