#include <bits/stdc++.h>
using namespace std;
int main(int argc, char** argv) {
  int n, x;
  cin >> n >> x;
  int l, r;
  vector<pair<int, int>> m;
  int sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> l >> r;
    m.push_back(make_pair(l, r));
    sum += r - l + 1;
  }
  l = 1;
  for (int i = 0; i < m.size(); i++) {
    while (l + x <= m[i].first) l += x;
    sum += m[i].first - l;
    l = m[i].second + 1;
  }
  cout << sum << endl;
  return 0;
}
