#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int i, j, k;
  long long int n, x;
  long long int s, e, count = 0;
  cin >> n >> x;
  pair<long long int, long long int> a[n];
  for (i = 0; i < n; i++) {
    cin >> s >> e;
    a[i] = make_pair(s, e);
  }
  long long int ag = 1;
  for (i = 0; i < n; i++) {
    while (ag + x <= a[i].first) ag += x;
    count += a[i].second - ag + 1;
    ag = a[i].second + 1;
  }
  cout << count;
  return 0;
}
