#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x, m = 1, c = 0;
  cin >> n >> x;
  int arr[n][2];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 2; j++) {
      cin >> arr[i][j];
    }
    c += arr[i][1] - arr[i][0] + 1;
  }
  for (int i = 0; i < n; i++) {
    while (m + x <= arr[i][0]) m += x;
    while (m != arr[i][0]) {
      c++;
      m++;
    }
    m = arr[i][1] + 1;
  }
  cout << c;
  return 0;
}
