UTS needs a computer lab for the new building at 30 Humbert Street, and Mr. Ianine is in charge of buying new computers. Each desktop computer needs a keyboard and a monitor. Luckily, Mr. Ianine has coupons. The coupon lets him buy either keyboards or monitors, but it cannot be used for both keyboards and monitors.
Being the fair person that he is, Mr. Ianine wants all coupons to be treated equally. He defines the value of the coupon as , and he must ensure that all the coupons he uses have the same value.
After using the coupons at the store, Mr. Ianine pairs up his keyboards and monitors. Each pair will be used for one working computer, and any extra unpaired keyboards and monitors are kept away in the IT room. What is the maximum number of working computers that he can get?
Input Specification
The first line contains , the number of coupons that Mr. Ianine has.
The next lines contain two integers and , the number of keyboards and monitors that the coupon allows him to buy. It is guaranteed that and .
Output Specification
Output the maximum number of working computers that Mr. Ianine can get, by using coupons of the same value.
Constraints
Subtask 1 [10%]
for all .
Subtask 2 [30%]
Subtask 3 [60%]
No additional constraints.
Sample Input
6
1 4
7 1
0 5
4 1
4 4
2 3
Sample Output
6
Explanation for Sample Output
Mr. Ianine should use the coupons with value . He should use coupons and to buy keyboards, and coupons and to buy monitors. Then he will have working computers.
Comments