#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n, x;
  cin >> n >> x;
  int cur = 1, ans = 0;
  for (int i = 0; i < n; i++) {
    int l, r;
    cin >> l >> r;
    while (cur + x <= l) cur += x;
    while (cur <= r) cur++, ans++;
  }
  cout << ans;
  return 0;
}
