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