#!/usr/bin/env python3
"""
laps, change_time, core_round_time, decay_factor = map(int, input().split())
MAXLAPS = laps +1
get_run_time = [0] * (MAXLAPS + 1)
for i in range(1, MAXLAPS+1):
    get_run_time[i] = get_run_time[i-1] + core_round_time + decay_factor * (i-1) 
def total_time(tire_changes):
    
    Returns the total time with doing the provided number of tire changes
    
    # A 'run' is some number of laps until changin tires again.
    runs = tire_changes + 1
    # Observation: It is always better to spread out changes as evenly
    # as possible, since the last lap in the run most expensive.
    # Might not always be possible, so some runs become one lap longer
    laps_per_run = laps // runs
    long_runs = laps % runs
    short_runs = runs - long_runs
    assert(short_runs*laps_per_run + long_runs*(laps_per_run + 1) == laps)
    time_short_run = get_run_time[laps_per_run]
    time_long_run = get_run_time[laps_per_run + 1]
    return short_runs * time_short_run + long_runs * time_long_run + change_time * tire_changes
min_time = float('inf')
next_time = total_time(0)
i = 1
while next_time < min_time:
    min_time = next_time
    next_time = total_time(i)
    i += 1
print(min_time)
"""