#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x, i, c = 0, cur = 0;
  cin >> n >> x;
  int l[n], r[n];
  for (i = 0; i < n; i++) {
    cin >> l[i] >> r[i];
  }
  i = 0;
  while (i < n) {
    if (l[i] > cur + x) {
      cur += x;
    } else {
      c += (r[i] - cur);
      cur = r[i];
      i++;
    }
  }
  cout << c;
  return 0;
}
