#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int N = 100050;
int x[100], s[100];
int dp[N][100];
int ans;
int n, m;
int main() {
  cin >> n >> m;
  memset(dp, inf, sizeof(dp));
  for (int i = 1; i <= n; ++i) cin >> x[i] >> s[i];
  for (int i = 1; i <= n; ++i) dp[1][i] = max(0, x[i] - s[i] - 1);
  for (int i = 2; i <= m; ++i) {
    for (int j = 1; j <= n; ++j) {
      if (i > x[j] + s[j] && x[j] * 2 - i > 0)
        dp[i][j] = min(dp[i][j], dp[x[j] * 2 - i][j]);
      else if (i >= x[j] - s[j] && i <= x[j] + s[j])
        for (int k = 1; k <= n; ++k) dp[i][j] = min(dp[i][j], dp[i - 1][k]);
      else {
        for (int k = 1; k <= n; ++k) {
          if (j != k) {
            int now = max(i + s[j] - x[j], x[j] - s[j] - i);
            dp[i][j] = min(dp[i][j], dp[i - 1][k] + now);
          } else
            dp[i][j] = min(dp[i][j], dp[i - 1][k] + (x[j] <= i));
        }
      }
    }
  }
  ans = dp[0][0];
  for (int i = 1; i <= n; ++i) ans = min(ans, dp[m][i]);
  printf("%d\n", ans);
  return 0;
}
