Shot at a target
Agent Johnny English decided to practice shooting. To do this, he decided to do exactly shots. His pistol has a magazine with cartridges, which, of course, is not initially loaded.
Johnny English can fully reload his pistol in seconds or add one cartridge to the chamber in seconds. One shot takes exactly one second. Help him to find the minimum amount of time Agent Johnny English can make exactly shots. Of course, he cannot fire an empty pistol and cannot put a new cartridge into an already full magazine.
Input
The first line contains four integers and — 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
Print one number — the minimum time it will take for the agent to fire exactly shots.
Examples
During the test, Johnny had to fully load the pistol once, fire twice, then insert one cartridge and fire.