#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  pair<int, int> s[n + 1];
  for (int a = 0; a < n; a++) {
    int x, y;
    cin >> x >> y;
    s[a] = make_pair(max(x - y, 1), min(x + y, m));
  }
  sort(s, s + n);
  int dp[m + 1];
  dp[m] = 0;
  for (int a = m - 1; a >= 0; a--) {
    bool cover = 0;
    int minima = m - a;
    for (int b = 0; b < n; b++) {
      if (s[b].first <= (a + 1) && s[b].second >= (a + 1)) {
        cover = 1;
        break;
      } else if (s[b].first > (a + 1)) {
        minima = min(minima, dp[min(m, s[b].second + s[b].first - (a + 1))] +
                                 s[b].first - (a + 1));
      }
    }
    if (cover) {
      dp[a] = dp[a + 1];
    } else
      dp[a] = minima;
  }
  cout << dp[0];
}
