#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 20;
int n, m, dp[maxn], ans, le[100], ri[100];
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 1) + (x << 3) + (ch ^ 48);
    ch = getchar();
  }
  return x;
}
int main() {
  memset(dp, 0x3f3f3f3f, sizeof dp);
  n = read(), m = read();
  dp[m + 1] = 0;
  for (int i = 1; i <= n; ++i) {
    int x = read(), s = read();
    le[i] = max(1, x - s), ri[i] = min(m, x + s);
  }
  for (int i = m; i >= 1; --i) {
    dp[i] = dp[i + 1] + 1;
    for (int j = 1; j <= n; ++j) {
      if (le[j] <= i && i <= ri[j]) {
        dp[i] = dp[i + 1];
        break;
      }
      if (i < le[j]) {
        dp[i] = min(dp[i], dp[min(m + 1, le[j] + ri[j] + 1 - i)] + le[j] - i);
      }
    }
  }
  printf("%d", dp[1]);
  return 0;
}
