#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
long long pow_mod(long long x, int n) {
  long long res = 1;
  while (n) {
    if (n & 1) res = res * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}
struct Artenna {
  int x, s;
  bool operator<(const Artenna& a) const { return x < a.x; }
} a[85];
const int INF = 0x3f3f3f3f;
int dp[85][100005];
void test_case() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) scanf("%d%d", &a[i].x, &a[i].s);
  ++n;
  a[n].x = 0, a[n].s = 0;
  sort(a + 1, a + 1 + n);
  for (int i = 1; i <= n; ++i) memset(dp[i], INF, sizeof(dp[i][0]) * (m + 1));
  for (int j = 0; j <= m; ++j) dp[1][j] = j;
  for (int i = 2; i <= n; ++i) {
    for (int j = 0; j <= m; ++j) dp[i][j] = min(dp[i][j], dp[i - 1][j]);
    int l = max(0, a[i].x - a[i].s), r = min(m, a[i].x + a[i].s);
    for (int j = 0; j < l; ++j) {
      int p = min(m, a[i].x + (a[i].x - (j + 1)));
      int c = max(0, a[i].x - (j + 1) - a[i].s);
      dp[i][p] = min(dp[i][p], dp[i - 1][j] + c);
    }
    dp[i][r] = min(dp[i][r], dp[i - 1][l]);
    for (int j = r + 1; j <= m; ++j) {
      int p = max(0, a[i].x - (j - a[i].x));
      int c = max(0, j - a[i].x - a[i].s);
      dp[i][j] = min(dp[i][j], dp[i - 1][p] + c);
    }
    for (int j = m - 1; j >= 0; --j) dp[i][j] = min(dp[i][j], dp[i][j + 1]);
  }
  printf("%d\n", dp[n][m]);
  return;
}
int main() {
  int t = 1;
  for (int ti = 1; ti <= t; ++ti) {
    test_case();
  }
}
