#include <bits/stdc++.h>
using namespace std;
int kg, df;
int main() {
  int n, x;
  cin >> n >> x;
  int l[n], r[n];
  for (int i = 0; i < n; i++) {
    cin >> l[i] >> r[i];
    kg += r[i] - l[i] + 1;
  }
  int h = 1;
  for (int i = 0; i < n; i++) {
    kg += (l[i] - h) % x;
    h = r[i] + 1;
  }
  cout << kg;
}
