#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, t;
  cin >> n >> t;
  int total = 0;
  int current = 1;
  int l, r;
  for (int i = 0; i < n; i++) {
    cin >> l >> r;
    int temp = (l - current) / t;
    current += (t * temp);
    total += ((r - current) + 1);
    current = r + 1;
  }
  cout << total << endl;
}
