Milk Pails (Bronze)
Farmer John has received an order for exactly m units of milk that he needs to fill right away. Unfortunately, his fancy milking machine has just become broken, and all he has are three milk pails of integer sizes x, y and m. All three pails are initially empty. Using these three pails, he can perform any number of the following two types of operations:
He can fill the smallest pail (of size x) completely to the top with x units of milk and pour it into the size-m pail, as long as this will not cause the size-m pail to overflow.
He can fill the medium-sized pail (of size y) completely to the top with y units of milk and pour it into the size-m pail, as long as this will not cause the size-m pail to overflow.
Although FJ realizes he may not be able to completely fill the size-m pail, please help him determine the maximum amount of milk he can possibly add to this pail.
Input
One line contains x, y and m (1 ≤ x < y < m, 1 ≤ m ≤ 1000).
Output
Print the maximum amount of milk FJ can possibly add to the size-m pail.
Example
In this example, FJ fills the pail of size 17 three times and the pail of size 25 once, accumulating a total of 76 units of milk.