#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
const int maxn = 85;
const int maxm = 1e5 + 10;
int n, m;
pair<int, int> arr[maxm];
int dp[maxm * 2];
int main(void) {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) {
    int x, s;
    scanf("%d%d", &x, &s);
    arr[i] = {x - s, x + s};
  }
  sort(arr, arr + n);
  memset(dp, 0x3f, sizeof(dp));
  for (int i = 0; i < n; ++i) {
    int l = arr[i].first, r = arr[i].second;
    for (int j = 0; r + j <= m * 2; ++j) {
      dp[r + j] = min(dp[r + j], (l - j - 1 <= 0 ? 0 : dp[l - j - 1]) + j);
    }
    for (int j = m * 2; j > 0; --j) dp[j] = min(dp[j], dp[j + 1]);
  }
  printf("%d", dp[m]);
  return 0;
}
