#include <bits/stdc++.h>
using namespace std;
int T;
struct ev {
  int x, s;
};
ev v[85];
int st[85], dr[85];
int main() {
  int T;
  cin.tie(0)->sync_with_stdio(0);
  T = 1;
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> v[i].x >> v[i].s;
    st[i] = max(0, v[i].x - v[i].s);
    dr[i] = min(m, v[i].x + v[i].s);
  }
  vector<int> dp(2 * m + 5, 0);
  dp[0] = 0;
  for (int i = 1; i <= m; i++) {
    dp[i] = i;
    for (int j = 1; j <= n; j++) {
      int lft = st[j];
      int rgh = dr[j];
      if (lft <= i && i <= rgh) {
        dp[i] = min(dp[i], dp[i - 1]);
        break;
      }
      if (i > rgh) {
        int dist = i - rgh;
        int ant = max(0, st[j] - dist - 1);
        dp[i] = min(dp[i], dp[ant] + dist);
      }
    }
  }
  cout << dp[m] << " ";
}
