B. Forcefield
time limit per test
1 second
memory limit per test
256 mebibytes
input
standard input
output
standard output

While Luke Skywalker was trying to acquire confindental data from the imperial flagship, he got into a trap. Now he is standing on the very edge of a long pipe inside the spaceship's reactor. To deal with the situation, he can move only forward. There is a stormtrooper standing at some point in front of Luke, and he have just made a shot from a blaster towards Luke. At the same moment, R2-D2 has accidentally activated the spaceship's forcefield. The forcefield generators are located on the pipe. The generators are powerful enough to change the bolt movement direction.

Each generator reflects a bolt of plasma when it comes from the front side and lets it fly through when it comes from the back. However, if the bolt comes from the front, it destroys the generator. Therefore, there are two types of generators: generators of one type face towards Luke, and generators of the other type face in the opposite direction.

After a generator is destroyed, it no longer affects the bolt. The stormtrooper's batteries are low on charge, so he cannot shoot anymore and now is lying on the bottom of the pipe so that the bolt will not hit him.

When the bolt reaches Luke, he must reflect it with the use of his lightsaber. But because of the forcefield, after being reflected, the bolt just changes direction to the opposite and continues to fly along the pipe. Luke cannot move until all the generators are destroyed. Additionally, if after destroying all the generators, the bolt flies towards Luke again, he must reflect it one more time. So, now he wonders if it's possible to destroy all the generators, and if so, how many times he will have to reflect the plasma bolt.

Input

The first line of the input contains two integers N and X, the number of generators and the distance between Luke and the stormtrooper (1 ≤ N ≤ 100 000, 1 ≤ X ≤ 109).

The next N lines contain two integers each. The i-th line contains xi, the distance between Luke and the i-th generator, and the type of the generator (1 ≤ xi ≤ 109; the type is 1 if the generator is faced towards Luke, or 0 otherwise).

The generators are given in the order of increasing distance from Luke (that is, xi < xj if i < j). The position of the stormtrooper doesn't coincide with any of the generators.

Output

Print  - 1 if it's not possible to destroy all the generators.

Otherwise, print a single integer: the number of times Luke will have to reflect the bolt of plasma.

Example
Input
2 3
1 1
2 1
Output
3