Hide and Seek
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

Eva is playing a special "hide and seek" game with Colin. Dislike the traditional one, Eva picks a hidden positive integer x and let Colin guess.

First Eva will tell Colin a positive integer a and she guarantees that x\le a .

Then Eva will show Colin m constraints: each constraint is given by two non-negative integer b_j,c_j, meaning that b_j \text{ } \text{mod} \text{ } x = c_j \text{ } (1 \le j \le m) .

Colin wants to enumerate all possible integers, but he don't know there are how many of them. Can you tell Colin how many positive integers can suit all constraints above?

It's guaranteed there exists at least one integer which can suit all constraints above.

输入描述:

The first line contains two integers m,a \text{ }(1 \le m \le 2 \times 10^5,1 \le a \le 10^9) , representing the number of constraints and the upper bound of hidden integer x.

For the following m lines, each line contains two integers b_j, c_j \text{ }( 0 \le c_j \le b_j \le 10^9 ) , represents b_j \text{ } \text{mod} \text{ } x = c_j \text{ }(1 \le j \le m) .

输出描述:

A single line contains an integer, representing the number of positive integers which can suit all given constraints.
示例1

输入

复制
2 10
7 1
8 2

输出

复制
2