#include <bits/stdc++.h>
using namespace std;
void testCase() {}
int dp[1000000][2];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> v;
  for (int i = 0; i < n; i++) {
    int x, s;
    cin >> x >> s;
    v.push_back({x, s});
  }
  for (int i = 1; i <= m; i++) {
    dp[i][0] = 1e9;
    for (auto p : v) {
      int lisa = max(0, abs(p.first - i) - p.second);
      int val = 0;
      if (p.first < i) {
        int kohta = p.first - p.second - lisa - 1;
        if (kohta < 1) {
          val = lisa;
        } else {
          val = lisa + dp[kohta][1];
        }
      } else {
        val = lisa + dp[i - 1][1];
      }
      dp[i][0] = min(dp[i][0], val);
    }
    dp[i][1] = min(dp[i][0], 1 + dp[i - 1][1]);
  }
  cout << dp[m][0] << "\n";
}
