#include <bits/stdc++.h>
using namespace std;
long long n, m, dp[200200], pos[200200], dist[200200];
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> pos[i] >> dist[i];
  }
  dp[0] = 0;
  for (int i = 1; i <= m; i++) {
    dp[i] = i;
    for (int i1 = 1; i1 <= n; i1++) {
      int left = pos[i1] - dist[i1], right = pos[i1] + dist[i1];
      if (i >= left && i <= right) {
        dp[i] = dp[i - 1];
        break;
      }
      if (i > right) {
        int cnt = i - right;
        int poss = left - cnt - 1;
        dp[i] = min(dp[i], dp[max(poss, 0)] + cnt);
      }
    }
  }
  cout << dp[m] << endl;
}
