#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x;
  cin >> n >> x;
  int best_moments[n][2];
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < 2; ++j) {
      cin >> best_moments[i][j];
    }
  }
  long int time = 1;
  long int t_count = 0;
  for (int i = 0; i < n;) {
    if (best_moments[i][0] - time >= x) {
      time += x;
    } else {
      t_count += best_moments[i][1] - time + 1;
      time = best_moments[i][1] + 1;
      ++i;
    }
  }
  cout << t_count;
}
