#include<stdio.h>
int main()
{
int n, L , c;
int count = 0;
long long int x, y, i, j,max = 0,min=0,t;
int a[10001] = { 0 };
scanf("%d %d", &n, &L);
c = 0;
while (n--)
{
scanf("%lld %lld", &x,&y);
if (max < y)
{
max = y;
}
for (i = x; i < y; i += L)
{
for (j = 0; j < L; ++j)
{
t = i + j;
if (a[t] == 0)
{
a[t] = 1;
}
}
}
}
for (i = 0;; i++)
{
if (a[i] == 1)
{
min = i;
break;
}
}
for (i = min; i < max; i += L)
{
count = 0;
for (j = 0; j < L; ++j)
{
if (a[i + j] == 0)
i = i + j + 1;
if (a[i+j] == 1&&i+j<max)
{
count++;
}
}
if (count ==L)
c++;
}
printf("%d", c);
}