#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x, a, b, init = 1, minutes = 0;
  scanf("%d %d", &n, &x);
  while (n--) {
    scanf("%d%d", &a, &b);
    while (init + x <= a) init += x;
    minutes += b - init + 1;
    init = b + 1;
  }
  printf("%d", minutes);
}
