#include <bits/stdc++.h>
using namespace std;
bool comp(pair<int, int> a, pair<int, int> b) { return a.first < b.first; }
int main() {
  vector<pair<int, int> > v;
  int n, x;
  scanf("%d%d", &n, &x);
  for (int i = 0; i < n; ++i) {
    int l, r;
    scanf("%d%d", &l, &r);
    v.push_back(make_pair(l, r));
  }
  sort(v.begin(), v.end(), comp);
  int pos = 1;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int k = (v[i].first - pos) / x;
    pos += k * x;
    ans += v[i].second - pos + 1;
    pos = v[i].second + 1;
  }
  printf("%d\n", ans);
}
