#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x;
  cin >> n >> x;
  int ans = 0, p = 0;
  for (auto i = 0; i < n; ++i) {
    int l, r;
    cin >> l >> r;
    while (p + x < l) p += x;
    ans += (r - p);
    p = r;
  }
  cout << ans << endl;
  return 0;
}
