#include <bits/stdc++.h>
using namespace std;
long long n, x, i, k, c;
long long s[55];
long long f[55];
int main() {
  cin >> n >> x;
  c = 1;
  k = 0;
  for (i = 1; i <= n; i++) {
    cin >> s[i] >> f[i];
    while (c + x <= s[i]) {
      c += x;
    }
    k += f[i] - c + 1;
    c = f[i] + 1;
  }
  cout << k << endl;
  return 0;
}
