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