#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x, i, r, skip = 0, player = 1;
  cin >> n >> x;
  while (n--) {
    cin >> i >> r;
    while (player + x <= i) {
      player += x;
    }
    skip = skip + (r - (player - 1));
    player = r + 1;
  }
  cout << skip << "\n";
}
