#include <bits/stdc++.h>
using namespace std;
inline void In(long long _, ...) {
  va_list lis;
  va_start(lis, _);
  while (_--) scanf("%lld", va_arg(lis, long long*));
}
inline void Out(long long _, ...) {
  va_list lis;
  va_start(lis, _);
  while (_--) printf("%lld\n", va_arg(lis, long long));
}
inline void Out_(long long _, ...) {
  va_list lis;
  va_start(lis, _);
  while (_--) printf("%lld ", va_arg(lis, long long));
  puts("");
}
const int N = 1E5 + 10;
struct Antenna {
  int iniLeft, iniRight;
} a[N];
long long f[N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    int center, iniScope;
    cin >> center >> iniScope;
    a[i].iniLeft = max(0, center - iniScope);
    a[i].iniRight = min(m, center + iniScope);
  }
  f[m] = 0;
  for (int j = m; j >= 0; --j) {
    f[j] = (m - j);
    for (int i = 1; i <= n; ++i) {
      int l = a[i].iniLeft, r = a[i].iniRight;
      if (l <= j + 1 && j + 1 <= r) {
        f[j] = f[j + 1];
        break;
      }
      if (j < l) {
        int accessCost = (l - j - 1);
        int nextPos = min(m, r + accessCost);
        f[j] = min(f[j], accessCost + f[nextPos]);
      }
    }
  }
  cout << f[0] << "\n";
  return 0;
}
