#include <bits/stdc++.h>
int n, x, l, r, ans, now;
int main() {
  while (~scanf("%d%d", &n, &x)) {
    now = 1;
    ans = 0;
    while (n--) {
      scanf("%d%d", &l, &r);
      while (now + x <= l) now += x;
      ans += r - now + 1;
      now = r + 1;
    }
    printf("%d\n", ans);
  }
  return 0;
}
