#include <bits/stdc++.h>
const long long mod = 1000000007;
using namespace std;
int main() {
  long n, x;
  cin >> n >> x;
  long* l = new long[n + 1];
  long* r = new long[n + 1];
  l[0] = 1;
  r[0] = 1;
  for (long i = 1; i <= n; i++) {
    cin >> l[i] >> r[i];
  }
  long total = 0;
  long prev = r[0];
  for (long i = 1; i <= n; i++) {
    if ((l[i] - prev) < x) {
      total += (l[i] - prev) + (r[i] - l[i] + 1);
    } else {
      total += ((l[i] - prev) - ((l[i] - prev) / x) * x) + (r[i] - l[i] + 1);
    }
    prev = r[i] + 1;
  }
  cout << total << endl;
  delete[] l;
  delete[] r;
}
