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