#include <bits/stdc++.h>
using namespace std;
int skip(int x, int i) { return (i + x); }
int main() {
  int n, c = 0, current = 1;
  long long x;
  cin >> n >> x;
  long long a[n][2];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 2; j++) {
      cin >> a[i][j];
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 2; j++) {
      while (skip(x, current) <= a[i][0]) current = skip(x, current);
      while (current <= a[i][1]) {
        c++;
        current++;
      }
    }
  }
  cout << c;
}
