#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x, a, b, p;
  cin >> n >> x;
  int ans = 0;
  cin >> a;
  ans += (int)((a - 1) / x) * x;
  for (int i = 0; i < n - 1; i++) {
    cin >> a >> b;
    ans += (int)((b - 1 - a) / x) * x;
  }
  cin >> p;
  cout << p - ans;
  return 0;
}
