#include <bits/stdc++.h>
using namespace std;
template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> P) {
  return os << "(" << P.first << "," << P.second << ")";
}
template <class T>
ostream& operator<<(ostream& os, vector<T> V) {
  os << "[ ";
  for (auto v : V) os << v << " ";
  return os << "]";
}
template <class T>
ostream& operator<<(ostream& os, set<T> second) {
  os << "{ ";
  for (auto s : second) os << s << " ";
  return os << "}";
}
template <class T>
ostream& operator<<(ostream& os, multiset<T> second) {
  os << "{ ";
  for (auto s : second) os << s << " ";
  return os << "}";
}
template <class L, class R>
ostream& operator<<(ostream& os, map<L, R> M) {
  os << "{ ";
  for (auto m : M) os << "(" << m.first << ":" << m.second << ") ";
  return os << "}";
}
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cout << name << " : " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " |";
  __f(comma + 1, args...);
}
void solve() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int> > x(n);
  for (pair<int, int>& i : x) cin >> i.first >> i.second;
  vector<int> DP(m + 1);
  for (int i = 1; i <= m; ++i) {
    DP[i] = i;
    for (pair<int, int> p : x) {
      if (p.first - p.second <= i and i <= p.first + p.second) {
        DP[i] = DP[i - 1];
      }
      if (p.first + p.second < i) {
        int ex = 0;
        if (p.first - (i - p.first) - 1 > 0)
          ex = DP[p.first - (i - p.first) - 1];
        DP[i] = min(DP[i], i - (p.first + p.second) + ex);
      }
    }
  }
  cout << DP[m] << '\n';
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int T = 1, tc = 1;
  while (T--) {
    solve();
  }
  return 0;
}
