#include <bits/stdc++.h>
using namespace std;
int tab[100][2];
int main() {
  int n, x;
  bool trwa = 0;
  int wat = 0, b = 0;
  scanf("%d%d", &n, &x);
  for (int i = 0; i < n; i++) scanf("%d%d", &tab[i][0], &tab[i][1]);
  int pos = 1;
  while (b < n) {
    if (trwa == 0 && pos == tab[b][0])
      trwa = 1;
    else if (trwa && pos > tab[b][1]) {
      trwa = 0;
      b++;
    } else if (trwa == 0 && pos + x <= tab[b][0])
      pos += x;
    else {
      pos++;
      wat++;
    }
  }
  printf("%d\n", wat);
}
