#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, x, l, r, cnt = 0, i, cnt2 = 1;
  cin >> n >> x;
  for (i = 0; i < n; ++i) {
    cin >> l >> r;
    while ((cnt2 + x) <= l) cnt2 += x;
    cnt += 1 + r - cnt2;
    cnt2 = r + 1;
  }
  cout << cnt;
  return 0;
}
