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