Under construction

Still being built. Things may change

Herb Mixing

Interview

Time limit1sMemory limit2048 MB

Summary
Given counts of green and red herbs, find the maximum health boost from combining them using the listed recipes.
Level

Medium4 of 10

Topics
Dynamic programming, Implementation
Solved
No attempts yet

Problem

Leon has collected some herbs of two possible colors: green and red. Leon's health level will be boosted after he eats those herbs. Mixing the herbs can increase their effect according to the following recipes:

  • One green herb: Boosts health by 11.
  • Two green herbs: Boosts health by 33.
  • Three green herbs: Boosts health by 1010.
  • One green herb and one red herb: Boosts health by 1010.

The herbs cannot be consumed in any way other than those listed above.

What is the maximum amount of Leon's health that can be boosted if he optimally mixes and eats his herbs?

Input

Input contains two integers between 00 and 100100 (both inclusive), the number of green herbs and the number of red herbs that Leon has collected.

Output

Output a single integer, the maximum amount of Leon's health that can be boosted.

Examples2

  1. Example 1

    Input
    8 3
    
    Expected output
    43
    
  2. Example 2

    Input
    0 2
    
    Expected output
    0