#include <bits/stdc++.h>
using namespace std;
const int ONE = 1 << 10;
const int TWO = 1 << 11;
const int FOUR = 1 << 12;
const int EIGHT = 1 << 13;
const int SIXTEEN = 1 << 14;
const int THIRTY = 1 << 15;
const int SIXTY = 1 << 16;
const int ONE_HUNDRED = 1 << 17;
const int TWO_HUNDRED = 1 << 18;
const int FIVE_HUNDRED = 1 << 19;
const int MILLION = 1 << 20;
void reads(string &s) {
  char c;
  s.clear();
  while (true) {
    c = getchar();
    if (c != ' ' && c != '\n') {
      s += c;
      break;
    }
  }
  while (true) {
    c = getchar();
    if (c != ' ' && c != '\n')
      s += c;
    else
      break;
  }
}
void prints(string s) {
  int i, sz = s.size();
  for (i = 0; i < sz; i++) printf("%c", s[i]);
}
string takes(string s, int from, int to) {
  int i;
  string ans;
  ans.clear();
  for (i = from; i <= to; i++) ans += s[i];
  return ans;
}
int n, l[64], r[64], x;
void input() {
  scanf("%d", &n);
  scanf("%d", &x);
  for (int i = 1; i <= n; i++) scanf("%d %d", &l[i], &r[i]);
}
void solve() {
  int current_moment = 1;
  int current_minute = 1;
  int cnt = 0;
  while (current_moment <= n) {
    if (current_minute + x <= l[current_moment]) {
      current_minute += x;
      continue;
    } else {
      cnt += (r[current_moment] - current_minute + 1);
      current_minute = r[current_moment] + 1;
      current_moment++;
    }
  }
  printf("%d\n", cnt);
}
int main() {
  input();
  solve();
  return 0;
}
