#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  int n, x;
  cin >> n >> x;
  int pos = 1;
  int ans = 0;
  while (n--) {
    int l, r;
    cin >> l >> r;
    while (pos < l) {
      if (pos + x <= l) {
        pos += x;
      } else {
        pos++;
        ans++;
      }
    }
    ans += r - l + 1;
    pos = r + 1;
  }
  cout << ans << "\n";
  return 0;
}
