#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, k;
  cin >> n >> k;
  long long int a[n][2];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 2; j++) {
      cin >> a[i][j];
    }
  }
  long long int count = 0;
  long long int start = 0;
  for (int i = 0; i < n; i++) {
    while (start + k < a[i][0]) {
      count++;
      start = start + k;
    }
    start = a[i][1];
  }
  cout << start - (count * k);
  return 0;
}
