#include <bits/stdc++.h>
using namespace std;
int l[107], r[107];
int main() {
  int n, x, res = 0;
  cin >> n >> x;
  for (int i = 1; i <= n; i++) scanf("%d%d", l + i, r + i);
  for (int i = 1; i <= n; i++)
    res += (l[i] - r[i - 1] - 1) % x + (r[i] - l[i]) + 1;
  cout << res << endl;
  return 0;
}
