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