$L$ squares are lined up in a row on the left and right. The pieces are placed on top of some of the squares. Each piece is marked with an arrow pointing to the left or to the right. No more than one piece can be placed on a single square.
A piece in any square can be moved to an unoccupied square, but it can only be moved to an adjacent square and only one piece can be moved at a time. A piece can be moved to the left or to the right regardless of the direction of the arrow. However, if a piece is moved once in the direction of the arrow, one point is obtained, but if it is moved once in the opposite direction, one point is deducted. In addition, it is known that there is always a maximum number of points that can be scored, no matter what the starting situation is.
Given the number of squares and the situation of the pieces, write a program that calculates the maximum number of points that can be obtained. However, we assume that the squares are assigned numbers from 1 to $L$, starting from the left end of the column.
The input is given in the following form.
$N$ $L$ $p_1$ $d_1$ $p_2$ $d_2$ : $p_N$ $d_N$
The first line gives the number of pieces $N$ ($1 \leq N \leq 10^5$) and the number of squares $L$ ($N \leq L\leq 10^9$). The next $N$ lines give the number of squares where the pieces are placed $p_i$ ($1 \leq p_i\leq L$), and the direction of the arrows on the pieces $d_i$ (0 or 1). When $d_i$ is 0, the arrow is facing left, and when $d_i$ is 1, it is facing right. The same square number cannot be given (for $i \ne j$, $p_i \ne p_j$).
Output the maximum number of points that can be obtained in a line.
2 10 3 0 6 1
6
2 8 2 1 8 0
5
2 8 1 0 8 1
0