#include <bits/stdc++.h>
using namespace std;
struct f {
  int x;
  int y;
} arr[1001];
bool co(struct f c, struct f v) { return c.x <= v.x; }
int main() {
  long long n, r, i;
  scanf("%I64d %I64d", &n, &r);
  for (i = 0; i < n; i++) {
    scanf("%I64d %I64d", &arr[i].x, &arr[i].y);
  }
  sort(arr, arr + n, co);
  long long x1 = 1;
  long long t = 0;
  for (i = 0; i < n; i++) {
    while (arr[i].x != x1) {
      if (arr[i].x >= (x1 + r))
        x1 += r;
      else {
        t = t + (arr[i].x - x1);
        x1 = arr[i].x;
      }
    }
    t = t + arr[i].y - arr[i].x + 1;
    x1 = arr[i].y + 1;
  }
  printf("%I64d\n", t);
  return 0;
}
