#include <bits/stdc++.h>
using namespace std;
struct node {
  int l, r;
} movie[60];
int main(void) {
  int n, x;
  cin >> n >> x;
  int t = 1;
  for (int i = 1; i <= n; i++) scanf("%d%d", &movie[i].l, &movie[i].r);
  int ans = 0;
  for (int i = 1; i <= n;) {
    if (t + x > movie[i].l) {
      ans += movie[i].r - t + 1;
      t = movie[i].r + 1;
      i++;
    } else
      t += x;
  }
  cout << ans << endl;
}
