#include <bits/stdc++.h>
using namespace std;
const int maxn = 200005;
int n, m;
int x[maxn], s[maxn], dp[maxn];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d%d", &x[i], &s[i]);
  for (int i = 1; i <= m; i++) dp[i] = i;
  for (int i = 1; i <= m; i++)
    for (int j = 1; j <= n; j++)
      if (x[j] <= i)
        dp[i] =
            min(dp[i], dp[max(0, x[j] * 2 - i - 1)] + max(0, i - x[j] - s[j]));
      else
        dp[i] = min(dp[i], dp[max(0, x[j] - s[j] - 1)]);
  printf("%d", dp[m]);
  getchar();
  getchar();
  return 0;
}
