#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int inf = 1e9;
const long long llf = 1e18;
const int mod = 1e9 + 7;
const int maxn = 1e5 + 10;
int n, x;
int l[55], r[55];
int main() {
  cin >> n >> x;
  for (int i = 1; i <= n; i++) {
    cin >> l[i] >> r[i];
  }
  int t = 1, ans = 0;
  for (int i = 1; i <= n; i++) {
    int k = (l[i] - t) / x;
    t += k * x;
    ans += r[i] - t + 1;
    t = r[i] + 1;
  }
  cout << ans << endl;
  return 0;
}
