#include <bits/stdc++.h>
using namespace std;
int n, x, t, mmnt;
long long cnt = 0;
pair<int, int> a[55];
int main() {
  cin >> n >> x;
  for (int i = 1; i <= n; i++) cin >> a[i].first >> a[i].second;
  mmnt = t = 1;
  while (t <= a[n].second) {
    if (t == a[mmnt].first) {
      cnt += (a[mmnt].second - a[mmnt].first + 1);
      t = a[mmnt].second + 1;
      mmnt++;
      continue;
    }
    if (t + x <= a[mmnt].first) {
      t += x;
    } else {
      cnt += (a[mmnt].first - t);
      t = a[mmnt].first;
    }
  }
  cout << cnt;
  return 0;
}
