#include <bits/stdc++.h>
using namespace std;
int n, x, l, r;
int res = 0, skip = 1, sum = 0;
vector<int> a;
int main() {
  cin >> n >> x;
  int N = n;
  while (N--) {
    cin >> l >> r;
    while (skip <= l) {
      skip = skip + x;
    }
    skip = skip - x;
    res = r - (skip) + 1;
    sum = sum + res;
    skip = r + 1;
  }
  cout << sum;
}
