#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x;
  cin >> n >> x;
  int count = 0;
  int current = 1;
  while (n--) {
    int l, r;
    cin >> l >> r;
    while (current + x <= l) current += x;
    count += r - current + 1;
    current = r + 1;
  }
  cout << count;
}
