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