#include <bits/stdc++.h>
using namespace std;
int main() {
  int pos = 1;
  int n, x;
  cin >> n >> x;
  int i;
  vector<pair<int, int> > v;
  for (i = 0; i < n; i++) {
    int l, r;
    cin >> l >> r;
    v.push_back(make_pair(l, r));
  }
  sort(v.begin(), v.end());
  int M = 0;
  for (i = 0; i < v.size(); i++) {
    while (pos + x <= v[i].first) {
      pos += x;
    }
    M += (v[i].second - pos + 1);
    pos = v[i].second + 1;
  }
  cout << M;
  return 0;
}
