#include <bits/stdc++.h>
using namespace std;
int main() {
  int times, skip, total = 0;
  cin >> times >> skip;
  int arr[times * 2 + 1];
  arr[0] = 0;
  for (int i = 1; i < times * 2 + 1; i++) cin >> arr[i];
  for (int i = 0; i < times * 2; i = i + 2) {
    while (arr[i] + skip < arr[i + 1]) {
      total = total + skip;
      arr[i] = arr[i] + skip;
    }
  }
  cout << arr[times * 2] - total;
  return 0;
}
