#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 7;
long long n, m, cnt;
void read(int &x) {
  char ch = getchar();
  x = 0;
  for (; ch < '0' || ch > '9'; ch = getchar())
    ;
  for (; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
}
long long a[150], b[150];
long long dp[maxn];
int main() {
  scanf("%lld%lld", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%lld%lld", &a[i], &b[i]);
  for (int i = 1; i <= m; i++) {
    dp[i] = 10000000;
    for (int j = 1; j <= n; j++) {
      long long l = a[j] - b[j];
      long long r = a[j] + b[j];
      if (l <= i && r >= i) dp[i] = min(dp[i], dp[i - 1]);
      if (l > i) dp[i] = min(dp[i], dp[i - 1] + 1);
      if (r < i) dp[i] = min(dp[i], dp[max(0ll, l - (i - r) - 1)] + i - r);
    }
  }
  cout << dp[m] << endl;
  return 0;
}
