#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, l, r, k = 0, d = 0;
  cin >> n >> m;
  while (n--) {
    cin >> l >> r;
    while (l) {
      if (k >= l) {
        d += m;
        d += r - k;
        k = r;
        break;
      }
      k += m;
    }
  }
  cout << d;
  return 0;
}
