Bill never works or does anything productive in Mr.Hsiung's class. So, Mr.Hsiung orders him to fill up his water bottle, with a capacity of liters. Bill wants to delay this as much as possible, so he decides to fill Mr.Hsiung's bottle with 2 smaller bottles with capacity and . He can't fill Mr.Hsiung's bottle directly, but he can fill either of his bottles full, and then dump all of its contents into Mr.Hsiung's bottle as many times as he wants. Of course, Bill cannot overflow Mr.Hsiung's bottle. Can you help him find the maximum amount Mr.Hsiung's bottle can be filled without overflowing?
Input Specification
The first line will contain each separated by a space.
Output Specification
Output the maximum amount of water Mr.Hsiung's bottle can contain when Bill fills them.
Sample Input 1
3 2 10
Sample Output 1
10
Explanation 1
In this case, the entire bottle can be filled by using the second bottle times.
Sample Input 2
5 7 13
Sample Output 2
12
Explanation 2
In this case, Bill can use both bottles once to fill Mr.Hsiung's bottle up to liters.
Comments