#include <bits/stdc++.h>
using namespace std;
int main() {
  long int x, c = 0;
  int i, n, j = 1;
  cin >> n >> x;
  for (i = 1; i <= n; i++) {
    long int p, q;
    cin >> p >> q;
    while (1) {
      if (j + x > p) {
        c += q - j + 1;
        j = q + 1;
        break;
      }
      j += x;
    }
  }
  cout << c;
  return 0;
}
