There shall be one measure of wine throughout our kingdom.
- Magna Carta (1215), Clause 35
You are an official tasked with standardizing the kingdom's weights and measures. Everyone measures weight in pounds, but the pound weights that cities have used for generations differ in mass. Merchants continue to use the weights they are familiar with, and trading customs vary from city to city, making standardization difficult.
To investigate these differences, the royal court used the grain, a unit defined using a small reference weight kept at court. By comparing each city's pound weight with this reference, the court determined how many grains make up pound in that city. It then sent a separate standard weight to several cities and collected their measurements to establish a new unit of weight for common use in trade between cities.
Each city recorded the standard weight's measurement in pounds, discarding any fraction of pound. However, the standard weight was lost in transit between cities, so it can no longer be checked directly. Moreover, some of the reports appear to have been recorded incorrectly. The court's reference weight and each city's pound weight still exist, so you now wish to compare the reports using the verified masses of the local pounds.
You are given measurement records. In city , pound is grains, and the weight was recorded as pounds. The actual weight, expressed in grains, is a positive integer. Assume that correct records have no measurement error other than the rounding down described above.
The first line contains the number of measurement records .
The -th of the next lines contains and , separated by a space.
Print the minimum number of records to discard.
In the first example, if the weight is grains, the first city records pounds and the second records pounds. Discarding the third record allows both remaining records to be correct. All three records cannot be correct simultaneously.
In the second example, if the weight is grains, the first city must record pounds. The two records cannot both be correct, so one must be discarded.
Find the minimum number of records to discard so that all remaining records can be correct simultaneously. You may discard every record if necessary.
In the third example, both records are correct if the weight is grains.
In the fourth example, the record would be correct only if the actual weight were grains. Since the actual weight must be a positive integer, this record must be discarded.