Shot at a target
Shot at a target
Agent Johnny English decided to practice shooting. To do this, he decided to do exactly n shots. His pistol has a magazine with m cartridges, 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 and b~(1 \le n, m, a, b \le 10^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.
Examples
During the test, Johnny had to fully load the pistol once, fire twice, then insert one cartridge and fire.
3 2 1 1
5