#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long double PI = acosl(-1);
const long long infl = 1e15;
const int inf = 2e9;
const int nmax = 1e5 + 10;
const int MAXLG = log2(nmax) + 1;
int n, m;
int dp[nmax];
vector<pair<int, int> > renj;
int rec(int pos) {
  if (pos > m) return 0;
  int &ret = dp[pos];
  if (ret != -1) return ret;
  ret = inf;
  for (pair<int, int> z : renj) {
    if (z.first <= pos and pos <= z.second)
      ret = min(ret, rec(z.second + 1));
    else if (z.second < pos)
      ret = min(ret, rec(pos + 1) + 1);
    else
      ret = min(ret, z.first - pos + rec(z.second + 1 + z.first - pos));
  }
  return ret;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    int x, s;
    cin >> x >> s;
    renj.push_back({x - s, x + s});
  }
  memset(dp, -1, sizeof dp);
  cout << rec(1) << endl;
}
