#include <bits/stdc++.h>
using namespace std;
struct node {
  int l, r;
} s[100];
int cmp(node a, node b) { return a.l < b.l; }
int main() {
  int n, m, x;
  while (~scanf("%d%d", &n, &x)) {
    int cnt = 0;
    for (int i = 0; i < n; i++) {
      scanf("%d%d", &s[i].l, &s[i].r);
      cnt += s[i].r - s[i].l + 1;
    }
    sort(s, s + n, cmp);
    int before = 1;
    int i = 0;
    while (i < n) {
      cnt += (s[i].l - before) % x;
      before = s[i].r + 1;
      i++;
      while (before >= s[i].l) {
        before = s[i].r;
        i++;
      }
    }
    printf("%d\n", cnt);
  }
  return 0;
}
