#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x;
  cin >> n >> x;
  int a[n][2], sum = 0;
  for (int i = 0; i < n; i++) cin >> a[i][0] >> a[i][1];
  int j = 1, i = 0, m = a[0][0];
  while (j <= a[n - 1][0]) {
    if (j + x == m || j == m) {
      sum += a[i][1] - a[i][0] + 1;
      j = a[i][1] + 1;
      i++;
      m = a[i][0];
    } else if (j + x > m) {
      j++;
      sum += 1;
    } else if (j + x < m)
      j = j + x;
  }
  cout << sum << endl;
}
