#abc265a. [abc265_a]Apple
[abc265_a]Apple
Problem Statement
A fruit store sells apples.
You may perform the following operations as many times as you want in any order:
- Buy one apple for yen (the currency in Japan).
- Buy three apples for yen.
How much yen do you need to pay to obtain exactly apples?
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer as an integer.
Sample Input 1
10 25 10
Sample Output 1
85
Buy three apples for yen three times and one apple for yen, and you will obtain exactly apples for a total of yen.
You cannot obtain exactly apples for a lower cost, so the answer is yen.
Sample Input 2
10 40 10
Sample Output 2
100
It is optimal to buy an apple for yen times.
Sample Input 3
100 100 2
Sample Output 3
200
The only way to obtain exactly apples is to buy an apple for yen twice.
Sample Input 4
100 100 100
Sample Output 4
3400