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