#include <bits/stdc++.h>   using namespace std;   int n, x, l[60], r[60], ans;   int main() {     scanf( %d %d , &n, &x);     for (int i = 1; i <= n; ++i) {       scanf( %d %d , &l[i], &r[i]);     }     for (int i = 1; i <= n; ++i) {       ans += (l[i] - r[i - 1] - 1) % x;       ans += r[i] - l[i] + 1;     }     printf( %d , ans);     return 0;   }   