#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int x;
  scanf("%d %d", &n, &x);
  long long watched = 0;
  int mins[2 * n];
  for (int i = 0; i < 2 * n; i++) {
    int from, after;
    scanf("%d %d", &from, &after);
    mins[i] = from;
    i++;
    mins[i] = after;
  }
  int current = 0;
  for (int i = 0; i < (2 * n); i += 2) {
    if ((current + x) >= mins[i]) {
      watched = watched + (mins[i + 1] - current);
      current = mins[i + 1];
    } else {
      i -= 2;
      current += x;
    }
  }
  cout << watched << endl;
}
