Ann has recently started commuting by subway. We know that a one ride subway ticket costs a rubles. Besides, Ann found out that she can buy a special ticket for m rides (she can buy it several times). It costs b rubles. Ann did the math; she will need to use subway n times. Help Ann, tell her what is the minimum sum of money she will have to spend to make n rides?


-----Input-----

The single line contains four space-separated integers n, m, a, b (1 ≤ n, m, a, b ≤ 1000) — the number of rides Ann has planned, the number of rides covered by the m ride ticket, the price of a one ride ticket and the price of an m ride ticket. 


-----Output-----

Print a single integer — the minimum sum in rubles that Ann will need to spend.


-----Examples-----
Input
6 2 1 2

Output
6

Input
5 2 2 3

Output
8



-----Note-----

In the first sample one of the optimal solutions is: each time buy a one ride ticket. There are other optimal solutions. For example, buy three m ride tickets.

Difficulty: interview

Starter code:

Solutions:
"""
Codeforces Contest 266 Div 2 Problem A

Author  : chaotic_iak
Language: Python 3.3.4
"""

def main():
    n,m,a,b = read()
    if b/m < a:
        if n%m and a * (n%m) > b:
            print((n//m + 1) * b)
        else:
            print((n%m) * a + (n//m) * b)
    else:
        print(n*a)

################################### NON-SOLUTION STUFF BELOW

def read(mode=2):
    # 0: String
    # 1: List of strings
    # 2: List of integers
    inputs = input().strip()
    if mode == 0: return inputs
    if mode == 1: return inputs.split()
    if mode == 2: return list(map(int, inputs.split()))

def write(s="\n"):
    if s is None: s = ""
    if isinstance(s, list): s = " ".join(map(str, s))
    s = str(s)
    print(s, end="")

write(main())

(n, m, a, b) = list(map(int, input().split()))
ans = min(a * n, b * (n//m) + a * (n % m), b * (n//m) + b)
print(ans)


import sys

n, m, a, b = [int(x) for x in sys.stdin.readline().split()]
if b/m >= a:
    print(n*a)
else:
    res = b*(n//m)
    if (n % m)*a < b: res += (n % m)*a
    else: res += b
    print(res)

n, m, a, b = list(map(int, input().split()))
res = 10 ** 100

for i in range(10000):
    res = min(res, i * b + max(n - i * m, 0) * a)
print(res)


def main():
    n, m, a, b = list(map(int, input().split(' ')))
    c = 0
    if b / m < a:
        c += n // m * b
        n %= m
    else:
        c += n * a
        n = 0
    if n != 0:
        c += min(n * a, b)
    print(c)

def __starting_point():
    main()

__starting_point()

__author__ = 'Gleb'
n,m,a,b=input().split()
n,m,a,b=int(n),int(m),int(a),int(b)
if a*m<b:
    print(a*n)
else:
    summ=int(n/m)*b
    n=n%m
    if a*n<b:
        print(summ+a*n)
    else:
        print(summ+b)

a,b,c,d = list(map(int,input().split()))
dd = d/b
if dd > c:
    print(c*a)
else:
    cnt = a // b
    cnt2  = a %b
    print(min(cnt * d + cnt2 * c ,(cnt+1)*d))


n,m,a,b=map(int,input().split())
if m*a<=b:
    print(n*a)
else:
    ans=n//m*b
    if n%m!=0:
        if (n%m)*a<b:
            ans+=a*(n%m)
        else:
            ans+=b
    print(ans)

import math

#input
n,m,a,b=map(int,input().split())

#variables

#main
print(min(math.floor(n/m)*b+(n%m)*a,(math.floor(n/m)+1)*b,a*n))

#!/usr/bin/env python
#coding: UTF-8

import fileinput

def solve(n, m, a, b):
    cost = 0
    if b < (m*a) and m > 0:
        cost = (n // m) * b
        cost += min(b, (n % m) * a)
    else:
        cost = n*a

    return cost


def __starting_point():
    for line in fileinput.input():
        n, m, a, b = list(map(int, line.split(' ')))

        sol = solve(n, m, a, b)
        print(sol)


__starting_point()

n,m,a,b=map(int,input().split())
if (b/m)>=a:
    print(a*n)
elif((n//m)*b+(n%m)*a < (n//m+1)*b): 
    print((n//m)*b+(n%m)*a)
else:
    print((n//m+1)*b)

def main():
    n, m, a, b = list(map(int, input().split()))

    if b / m >= a:
        print(n * a)
    else:
        print(min((n//m)*b+(n%m)*a, (n//m+1)*b))

def __starting_point():
    main()


__starting_point()

__author__ = 'sonerik'

import sys

inp = sys.stdin
# inp = open("a.txt")

all_drives, abon_drives, ord_price, abon_price = map(int, inp.readline().strip().split())

# print(all_drives, abon_drives, one_price, abon_price)

one_abon_price = abon_price / abon_drives

# print(one_abon_price, ord_price)

if one_abon_price < ord_price:  # abonement is better
    abons = all_drives // abon_drives
    ords = all_drives % abon_drives

    if abon_price < ords*ord_price:
        abons += 1
        ords = 0

    print(abons*abon_price + ords*ord_price)
else:
    print(all_drives*ord_price)

import math
n, m, a, b = list(map(int, input().split()))
a1 = math.ceil(n/m) * b
a2 = n * a
a3 = n//m * b + (n % m) * a
print(min([a1,a2,a3]))


data = input()
data = data.split()

rides_num = int(data[0])
ticket_rides = int(data[1])
ticket_price = int(data[3])
one_ride = int(data[2])

ticket_one_price = ticket_price/ticket_rides

sum = 0

if ticket_one_price < one_ride:
    num_of_tickets = int(rides_num/ticket_rides)
    sum += num_of_tickets*ticket_price
    rest = rides_num-(num_of_tickets*ticket_rides)
    
    if rest*one_ride < ticket_price:
        sum += rest*one_ride
    else: sum += ticket_price
    print(sum)

else: print(rides_num*one_ride)


n, m, a, b = list(map(int, input().split()))
print(min(n * a, n // m * b + n % m * a, (n + m - 1) // m * b))


n,m,a,b = list(map(int,list(input().split())))
k = 0
cost = b / m
if(cost <= a):
    k += int(n / m)*b
    if(n%m*a < b):
        k += (n%m)*a
    else:
        k+=b
else:
    k = a*n
print(k)
    


n, m, a, b = list(map(int, input().split()))
if n > m:
    if b < a * m:
        print(min((n // m) * b + (n - ((n // m) * m)) * a, ((n // m) * b) + b))
    else:
        print(n * a)
else:
    print(min(b, n * a))



n, m, a, b = list(map(int, input().split()))

if b / m < a:
    print(n // m * b + min(n % m * a, b))
else:
    print(a * n)


n,m,a,b=list(map(int,input().split()))

print(min(a*((n//m)*m),b*(n//m))+min((n%m)*a,b))


n, m, a, b = map(int, input().split())
ans = 0
if m * a >= b:
    ans += (n // m) * b
    n = n % m
if a * n > b and m >= n:
    ans += b
    n = 0
ans += n * a
print(ans)

n, m, a, b = (int(x) for x in input().split())
print(min(a * n, (n + m - 1) // m * b, n // m * b + n % m * a))

import math
a, b, c, d = list(map(int, input().split(' ')))
if d/b<=c:
    print(min(d*int(a/b)+a%b*c, d*math.ceil(a/b)))
else:
    print(a*c)


n, m, a, b = list(map(int, input().split()))

if float(a) < float(b) / m:
    ans = a * n
else:
    n_big, rest = divmod(n, m)
    ans = n_big * b + min(rest * a, b)

print(ans)


n, m, a, b = map(int, input().split())
s1 = a * n
s2 = n // m * b + n % m * a
s3 = (n + m - 1) // m * b
print(min(s1, s2, s3))