#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const double eps = 1e-11;
template <class T>
inline void checkmin(T &a, T b) {
  if (b < a) a = b;
}
template <class T>
inline void checkmax(T &a, T b) {
  if (b > a) a = b;
}
template <class T>
inline T sqr(T x) {
  return x * x;
}
using namespace std;
long long gcd(long long a, long long b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
priority_queue<int> pq[2];
bool SortBySecond(pair<int, int> &begin, pair<int, int> &end) {
  return begin.second < end.second;
}
vector<int> vi;
vector<int> vx;
vector<int> vy;
int unit[100001] = {
    0,
};
int main() {
  int n = 0;
  int x = 0;
  int cursor = 1;
  long long answer = 0;
  cin >> n >> x;
  int s, t;
  for (int i = 0; i < n; i++) {
    cin >> s >> t;
    while (1) {
      if (s < cursor + x) {
        break;
      } else
        cursor += x;
    }
    answer += (t - cursor + 1);
    cursor = t + 1;
  }
  cout << answer;
}
