#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x, t = 0, t1 = 1, j = 0;
  cin >> n >> x;
  int a[n][2];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 2; j++) cin >> a[i][j];
  }
  while (n--) {
    while (t1 + x <= a[j][0]) t1 = t1 + x;
    t += a[j][1] - t1 + 1;
    t1 = a[j][1] + 1;
    j++;
  }
  cout << t;
  return 0;
}
