#GD0000016. Cộng và nhân (Addition and Multiplication)
Cộng và nhân (Addition and Multiplication)
Addition and Multiplication
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
A board initially displays . Perform exactly operations. Each operation either doubles the current value or adds . Find the minimum possible value after exactly operations.
Input
The first line contains . The second line contains .
Output
Print the minimum possible value.
Subtasks
General constraints:
-
.
-
Subtask 1 (20 points): ,
-
Subtask 2 (30 points): ,
-
Subtask 3 (50 points): No additional constraints.
Examples
Input
4
3
Output
10
Explanation
Starting from , choose the smaller next value at every step: .