#include <bits/stdc++.h>
int main() {
  long int n, x, m = 0, l, r, k, i;
  scanf("%ld%ld", &n, &x);
  i = 1;
  while (n--) {
    scanf("%ld%ld", &l, &r);
    while (x + i <= l) i = x + i;
    m = r - i + 1 + m;
    i = r + 1;
  }
  printf("%ld\n", m);
  return 0;
}
