public void solve() throws IOException {
    int n = nextInt();
    int x = nextInt();
    
    boolean[] interesting = new boolean[100000];
    
    for (int i = 0; i < n; i++) {
      int start = nextInt() - 1;
      int end = nextInt() - 1;
      for (int j = start; j <= end; j++) {
        interesting[j] = true;
      }
    }
    
    int watched = 0;
    int consecutive = 0;
    for (int i = 0; i < 100000; i++) {
      watched++;
      if (interesting[i]) {
        consecutive = 0;
      } else {
        consecutive++;
      }
      if (consecutive == x) {
        consecutive = 0;
        watched -= x;
      }
    }
    watched -= consecutive;
    System.out.println(watched);
  }