Marin is an assistant chef at Plavi 9, a busy restaurant whose menu today includes stuffed paprikas. Every assistant chef knows that a paprika has to be young when it is stuffed, so Marin stuffs only the paprikas that are no older than X days. He serves the rest fresh, as an appetizer. A new law says that every paprika has to carry its ID card at all times, so Marin judges the age of a paprika from the number on the card it holds.
It is less known that paprikas have their own goals in life besides their official papers. From an early age a paprika knows whether it wants to be served fresh or stuffed once it grows up. The N paprikas now standing in line to be stuffed have a problem. Some of them want to be part of the dish but are too old, and some want to be served fresh but are about to be stuffed.
The paprikas do not know the number X that Marin picked, so they decided to correct the injustice this way. The first paprika tries to swap its ID card with the second one, then the second tries to swap with the third, and so on to the end of the line. Two paprikas swap their cards when the one currently holding the larger number wants to be stuffed and the one holding the smaller number does not. They do not swap if the two numbers are equal.
After all the swaps, Marin reads the number on the card each paprika holds. A paprika is stuffed when that number is at most X, and served fresh when the number is larger than X. Determine how many paprikas reach their goal in life.
The first line contains the integers N and X. (1≤N,X≤1000)
Each of the next N lines contains the integers a and b describing one paprika, in the order the paprikas stand in line. (1≤a≤1000, 0≤b≤1)
The number a is printed on the ID card of that paprika and is its age in days. The number b is its goal in life, 0 if it wants to be served fresh and 1 if it wants to be stuffed.
Print, on a single line, the number of paprikas that reach their goal in life.
In the first example every paprika is young enough, but not a single one of them wants to be stuffed.
In the second example every pair of adjacent paprikas swaps ID cards.