#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
int n, m;
int pos[100];
int h[100];
int memo[101000][100];
int solve(int i, int used) {
  i = min(i, m + 100);
  if (used != -1 && memo[i][used] != -1) {
    return memo[i][used];
  }
  if (i > m) return memo[i][used] = 0;
  if (i <= m && used == n - 1) return memo[i][used] = INT_MAX / 2ll;
  int rez = INT_MAX / 2ll;
  for (int j = used + 1; j < n; j++) {
    int dist = abs(pos[j] - i);
    rez =
        min(rez, max(0, dist - h[j]) + solve(pos[j] + max(dist, h[j]) + 1, j));
    dist = max(dist, m - pos[j]);
    rez =
        min(rez, max(0, dist - h[j]) + solve(pos[j] + max(dist, h[j]) + 1, j));
  }
  if (used == -1)
    return rez;
  else
    return memo[i][used] = rez;
}
int32_t main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  for (int i = 0; i < 101000; i++) {
    for (int j = 0; j < 100; j++) {
      memo[i][j] = -1;
    }
  }
  for (int i = 0; i < n; i++) {
    cin >> pos[i] >> h[i];
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n - 1; j++) {
      if (pos[j] > pos[j + 1]) {
        swap(pos[j], pos[j + 1]);
        swap(h[j], h[j + 1]);
      }
    }
  }
  int ans = solve(1, -1);
  cout << ans << endl;
}
