#include <bits/stdc++.h>   inline long long read() {     long long x = 0, f = 1;     char c = getchar();     for (; c >  9  || c <  0 ; c = getchar()) {       if (c ==  - ) f = -1;     }     for (; c >=  0  && c <=  9 ; c = getchar()) {       x = x * 10 + c -  0 ;     }     return x * f;   }   int dp[200005];   int a[85], r[85];   inline void work() {     int n = read(), m = read();     dp[m + 1] = 0;     for (int i = 1; i <= n; i++) a[i] = read(), r[i] = read();     for (int i = m; i; i--) {       dp[i] = dp[i + 1] + 1;       for (int j = 1; j <= n; j++) {         if (a[j] >= i) {           if (a[j] - r[j] <= i) {             dp[i] = std::min(dp[i], dp[std::min(m + 1, a[j] + r[j] + 1)]);           } else {             dp[i] = std::min(                 dp[i], a[j] - r[j] - i + dp[std::min(m + 1, 2 * a[j] - i + 1)]);           }         } else {           if (a[j] + r[j] >= i) {             dp[i] = std::min(dp[i], dp[std::min(m + 1, a[j] + r[j] + 1)]);           }         }       }     }     printf( %d n , dp[1]);   }   int main() {     work();     return 0;   }   