#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, x, l[100001], r[100001], i, j, count = 0, run = 1, temp = 0;
  scanf("%lld %lld", &n, &x);
  for (i = 0; i < n; i++) {
    scanf("%lld %lld", &l[i], &r[i]);
  }
  for (i = 0; i < n; i++) {
    while (run + x <= l[i]) {
      run = run + x;
    }
    count = count + (r[i] - (run - 1));
    run = r[i] + 1;
  }
  printf("%lld\n", count);
  return 0;
}
