Hide

Problem H
Hot Dog Deals

At the university shop the price for a single hot dog is $299$ ISK (Icelandic krónas), and the price for a soda is $249$ ISK. They also have two great deals:

  • A hot dog and a soda for $499$ ISK.

  • Two hot dogs and a soda for $549$ ISK.

A group of hungry university students have gathered outside the shop. Each of them wants to buy a certain number of hot dogs and a certain number of sodas. Being poor university students, they really have to be careful about how they spend their money. They realize that if they buy all their hot dogs and sodas together, and make good use of the two deals that the shop offers, they may be able to save a lot of money.

Input

One line with two non-negative integers $n$ and $m$ ($n,m \le 500$), the total number of hot dogs and the total number of sodas that the students want.

Output

Output the minimum total amount of ISK so that, together, the students can get their number of hot dogs and sodas.

Sample Input 1 Sample Output 1
1 2
748
Sample Input 2 Sample Output 2
2 2
798
Sample Input 3 Sample Output 3
3 5
1795
Sample Input 4 Sample Output 4
4 1
1098

Please log in to submit a solution to this problem

Log in