#include <bits/stdc++.h>
int min(int a, int b) { return a < b ? a : b; }
int max(int a, int b) { return a > b ? a : b; }
struct V {
  int x, s;
} vv[80];
int compare(const void *a, const void *b) {
  struct V *u = (struct V *)a;
  struct V *v = (struct V *)b;
  return u->x - v->x;
}
int ft[100000 + 1];
void update(int i, int n, int x) {
  while (i < n) {
    ft[i] = min(ft[i], x);
    i |= i + 1;
  }
}
int query(int i) {
  int x = 0x3f3f3f3f;
  while (i >= 0) {
    x = min(x, ft[i]);
    i &= i + 1;
    i--;
  }
  return x;
}
int main() {
  static int dp[100000 + 1];
  int n, m, i, j;
  scanf("%d%d", &n, &m);
  for (i = 0; i < n; i++) {
    struct V *v = &vv[i];
    scanf("%d%d", &v->x, &v->s), v->x--;
  }
  qsort(vv, n, sizeof *vv, compare);
  memset(ft, 0x3f, m * sizeof *ft);
  update(m - 0, m + 1, 0);
  for (i = 0; i < n; i++) {
    struct V *v = &vv[i];
    for (j = 0; j <= m; j++)
      dp[j] = min(query(min(m - (v->x - v->s - j), m)) + j, 0x3f3f3f3f);
    for (j = 0; j <= m; j++)
      update(max(m - (v->x + v->s + j + 1), 0), m + 1, dp[j]);
  }
  printf("%d\n", query(0));
  return 0;
}
