You have decided to watch the best moments of some movie. There are two buttons on your player: 
 1.  Watch the current minute of the movie. By pressing this button, you watch the current minute of the movie and the player automatically proceeds to the next minute of the movie. 1.  Skip exactly *x* minutes of the movie (*x* is some fixed positive integer). If the player is now at the *t*-th minute of the movie, then as a result of pressing this button, it proceeds to the minute (*t* + *x*). 
Initially the movie is turned on in the player on the first minute, and you want to watch exactly *n* best moments of the movie, the *i*-th best moment starts at the *l*<sub class="lower-index">*i*</sub>-th minute and ends at the *r*<sub class="lower-index">*i*</sub>-th minute (more formally, the *i*-th best moment consists of minutes: *l*<sub class="lower-index">*i*</sub>, *l*<sub class="lower-index">*i*</sub> + 1, ..., *r*<sub class="lower-index">*i*</sub>). 

Determine, what is the minimum number of minutes of the movie you have to watch if you want to watch all the best moments?
The first line contains two space-separated integers *n*, *x* (1 ≤ *n* ≤ 50, 1 ≤ *x* ≤ 10<sup class="upper-index">5</sup>) — the number of the best moments of the movie and the value of *x* for the second button.

The following *n* lines contain the descriptions of the best moments of the movie, the *i*-th line of the description contains two integers separated by a space *l*<sub class="lower-index">*i*</sub>, *r*<sub class="lower-index">*i*</sub> (1 ≤ *l*<sub class="lower-index">*i*</sub> ≤ *r*<sub class="lower-index">*i*</sub> ≤ 10<sup class="upper-index">5</sup>).

It is guaranteed that for all integers *i* from 2 to *n* the following condition holds: *r*<sub class="lower-index">*i* - 1</sub> &lt; *l*<sub class="lower-index">*i*</sub>.
n,x=(int(i) for i in input().split())
m=0
prev=1
for i in range(n):
    l,r=(int(i) for i in input().split())
    prev+=((l-prev)//x)*x
    m+=(r-prev+1)
print(m)