Competitions

# 2018 Цикл Интернет-олимпиад для школьников, первая командная олимпиада сезона, 14 октября

Time limit 1 second
Memory limit 128 MiB

Agent Johnny English met another enemy in front of him, whom he had to kill. To make sure that his clumsiness would not interfere with this, he decided to shoot him exactly n shots from his pistol. His pistol has a magazine for m rounds, which, of course, is not initially loaded.

Johnny English can fully reload his pistol in a seconds or add one cartridge to the chamber in b seconds. One shot takes exactly one second. Help him to find the minimum amount of time Agent Johnny English can make exactly n shots. Of course, he cannot fire an empty pistol and cannot put a new cartridge into an already full magazine.

## Input data

The first line contains four integers n, m, a и b (1n, m, a, b10^4) - the number of shots to be fired, the size of the pistol magazine, the time it takes to fully reload the magazine and the time to load one cartridge.

## Output data

Print one number - the minimum time it will take for the agent to fire exactly n shots.

#### Hint

During the test, Johnny had to fully load the pistol once, fire twice, then insert one cartridge and fire.

## Examples

Input example #1
3 2 1 1

Output example #1
5

Source 2018 Цикл Интернет-олимпиад для школьников, первая командная олимпиада сезона, October 14, Problem А