#include <bits/stdc++.h>
using namespace std;
struct s {
  long long x, y;
};
bool cmp(s a, s b) { return a.x < b.x; }
long long gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int main() {
  int n;
  int x;
  int cnt = 0;
  cin >> n >> x;
  vector<int> l(n);
  vector<int> m(n);
  for (int i = 0; i < (int)(n); ++i) {
    cin >> l[i] >> m[i];
  }
  int now = 1;
  int b = 0;
  while (true) {
    if (b >= n) break;
    if (l[b] >= now && l[b] >= now + x) {
      now += x;
    } else {
      cnt++;
      now++;
      if (now > m[b]) b++;
    }
  }
  cout << cnt << endl;
}
