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