#include <bits/stdc++.h>
using namespace std;
int dp[100010], l[10010], r[10010], n, m;
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    int a, b;
    cin >> a >> b;
    l[i] = max(1, a - b);
    r[i] = min(m, a + b);
  }
  dp[0] = 0;
  for (int i = 1; i <= m; i++) {
    dp[i] = i;
    for (int j = 1; j <= n; j++) {
      if (l[j] <= i && r[j] >= i) {
        dp[i] = dp[i - 1];
        break;
      }
      if (r[j] < i) {
        int num = i - r[j];
        dp[i] = min(dp[i], dp[max(0, l[j] - num - 1)] + num);
      }
    }
  }
  cout << dp[m] << endl;
}
