#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  long long n, x, i, ss = 0, t = 1, a, b;
  cin >> n >> x;
  while (n--) {
    cin >> a >> b;
    long long m = 0;
    while (1) {
      if ((t + x) > a) {
        m = 1;
      } else if ((t + x) <= a) {
        t += x;
        if ((t + x) > a) {
          m = 1;
        }
      }
      if (m == 1) {
        ss += (b - t + 1);
        break;
      }
    }
    t = b + 1;
  }
  cout << ss;
  return 0;
}
