#include <bits/stdc++.h>
using namespace std;
const int N = 1e5+5;
typedef long long ll;
int n; ll d[N], b[N], t;
int main () {
freopen("jieniu.in", "r", stdin);
freopen("jieniu.out", "w", stdout);
scanf("%d%lld", &n, &t);
for (int i = 1;i <= n;i++) scanf("%lld%lld", &d[i], &b[i]);
for (int i = n;i >= 1;i--) if (d[i] > t) n--;
ll s = 0, ans = 0; d[n+1] = t+1;
for (int i = 1;i <= n;i++) {
s += b[i];
ans += min(d[i+1]-d[i], s);
s = max(s-(d[i+1]-d[i]), 0ll);
}
printf("%lld\n", ans);
return 0;
}