#include <bits/stdc++.h>
using namespace std;
const int N = 100000 + 5, inf = 1e9 + 7;
int n, m, x, y, l, r, f[N];
struct tt {
  int l, r;
} a[100];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &x, &y);
    l = max(1, x - y), r = min(m, x + y);
    a[i].l = l, a[i].r = r;
  }
  for (int i = 1; i <= m; i++) {
    f[i] = i;
    for (int j = 1; j <= n; j++) {
      if (a[j].l <= i && i <= a[j].r)
        f[i] = min(f[i], f[i - 1]);
      else if (a[j].r < i)
        f[i] = min(f[i], i - a[j].r + f[max(0, a[j].l - i + a[j].r - 1)]);
    }
  }
  printf("%d\n", f[m]);
  return 0;
}
