#include <bits/stdc++.h>
int main() {
  int n, x;
  scanf("%d%d", &n, &x);
  int i, j, deb, fin, watched;
  watched = 0;
  j = 1;
  for (i = 0; i < n; i++) {
    scanf("%d%d", &deb, &fin);
    while (j + x <= deb) {
      j += x;
    }
    watched = watched + (fin - j) + 1;
    j = fin + 1;
  }
  printf("%d\n", watched);
  return 0;
}
