Go: package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() (int, error) {
	return strconv.Atoi(nextString())
}

func nextFloat64() (float64, error) {
	return strconv.ParseFloat(nextString(), 64)
}

func stringifyArray(arr []int) string {
	return strings.TrimRight(fmt.Sprintf("%+v", arr)[1:], "]")
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}
func main() {
	scanner.Split(bufio.ScanWords)

	n, _ := nextInt()
	a, _ := nextInt()
	b, _ := nextInt()
	c, _ := nextInt()
	d, _ := nextInt()

	costX := b * int(math.Ceil(float64(n)/float64(a)))
	costY := d * int(math.Ceil(float64(n)/float64(c)))
	fmt.Println(min(costX, costY))
}

Python: N, A, B, C, D = map(int, input().split())

if (A <= N or C <= N):
   if N % A == 0:
      X = int(N / A) * B
   else:
      X = int(N / A + 1) * B
   if N % C == 0:
      Y = int(N / C) * D
   else:
      Y = int(N / C + 1) * D
else:
   X = B
   Y = D
   
if X <= Y:
   print(int(X))
else:
   print(int(Y))

Python: N, A, B, C, D = map(int, input().split())
X = N//A + (N%A!=0)*1
Y = N//C + (N%C!=0)*1
print(min(X*B, Y*D))

Python: N, A, B, C, D = map(int, input().split())
print(min((N+A-1)//A*B, (N+C-1)//C*D))

Python: n, a, b, c, d = list(map(int, input().split()))
if n%a == 0:
    ya = (n//a)*b
else:
    ya = ((n//a)+1)*b
if n%c == 0:
    yc = (n//c)*d
else:
    yc = ((n//c)+1)*d    
ans = min([ya, yc])
print(ans)

Python: N, A, B, C, D = map(int, input().split())

if N%A == 0:x = N//A *B    
else:       x = (N//A +1) *B

if N%C == 0:y = N//C *D
else:       y = (N//C +1) *D

if x<=y: print(x)
else:    print(y)

Python: n,a,b,c,d=map(int,input().split())
if n%a==0 :k=n//a*b
else:k=(n//a+1)*b

if n%c==0 :l=n//c*d
else:l=(n//c+1)*d


print(min(k,l))

Python: N,A,B,C,D=map(int,input().split())
print(min((N+A-1)//A*B,(N+C-1)//C*D))

Python: n,a,b,c,d=map(int, input().split())
print(min((n+a-1)//a*b, (n+c-1)//c*d))

Python: import math
n,a,b,c,d = map(int,input().split())
x = math.ceil(n/a)*b
y = math.ceil(n/c)*d

if x <y:
    print(x)
else:
    print(y)

Python: n,a,b,c,d=map(int,input().split())
print(min((n+a-1)//a*b,(n+c-1)//c*d))

Python: N, A, B, C, D = map(int, input().split())
X = N//A + (N%A!=0)*1
Y = N//C + (N%C!=0)*1
print(min(X*B, Y*D))

Python: N,A,B,C,D=map(int,input().split())
print(min((N+A-1)//A*B,(N+C-1)//C*D))

Python: n, a, b, c, d = map(int, input().split())
costa = 0
costb = 0
num = 0
while(num < n):
    costa += b
    num += a
num = 0
while(num < n):
    costb += d
    num += c
print(min(costa, costb))

Python: N,A,B,C,D = map(int,input().split())
X = N//A
if N%A!=0:
    X=X+1
Y = N//C
if N%C!=0:
    Y=Y+1

print(min(X*B, Y*D))

Python: import math

n, a, b, c, d = map(int, input().split())

acost = math.ceil(n / a) * b 
ccost = math.ceil(n / c) * d
print (min(acost, ccost))

Python: N,A,B,C,D=map(int,input().split())
if N%A==0:
    X=N//A
else:
    X=N//A+1
if N%C==0:
    Y=N//C
else:
    Y=N//C+1
if X*B<=Y*D:
    print(X*B)
else:
    print(Y*D)

Python: N, A, B, C, D = map(int, input().split())

a = N // A
c = N // C

if a * A < N :
    a += 1

if c * C < N :
    c += 1
    
b = a * B
d = c * D

if b < d :
    print(b)
else :
    print(d)

Python: from math import ceil
n, a, b, c, d = map(int, input().split())
print(min(ceil(n / a) * b, ceil(n / c) * d))

Python: n, a, b, c, d = map(int, input().split())
print(min((n+a-1)//a*b, (n+c-1)//c*d))

Python: s = input().split()
N = int(s[0])
A = int(s[1])
B = int(s[2])
C = int(s[3])
D = int(s[4])
if N%A == 0:
  X = int(N/A)
else:
  X = N//A+1
if N%C == 0:
  Y = int(N/C)
else:
  Y = N//C+1
X1 = X*B
Y1 = Y*D
if X1 >= Y1:
  print(Y1)
else:
  print(X1)

Python: N,A,B,C,D = map(int, input().split())
#XとYをセットの数とする
X = N//A
if N % A != 0: X+=1   # 割り切れなれば+1
Y = N//C
if N % C != 0: Y+=1   # 割り切れなれば+1
print(min(X*B, Y*D))

Python: n,A,b,C,d=map(int, input().split())

x=0
i=0

while i<n:
    x+=b
    i+=A

y=0
j=0

while j<n:
    y+=d
    j+=C

if x<y:
    print(x)
else :
    print(y)

Python: import math

N, A, B, C, D = map(int, input().split(' '))

a_count = math.ceil(N/A)
c_count = math.ceil(N/C)

a_cost = a_count * B
c_cost = c_count * D

print(min([a_cost, c_cost]))

Python: N,A,B,C,D,=map(int,input().split())

if 1<=N<=1000 and 1<=A<=1000 and 1<=B<=1000 and 1<=C<=1000 and 1<=D<=1000:
    if N%A==0:
        X=(N//A)*B
    
    else:
        X=(N//A+1)*B
        
    if N%C==0:
        Y=(N//C)*D
    else:
        Y=(N//C+1)*D
    
    if X<=Y:
        print(int(X))
    if X>Y:
        print(int(Y))
        

else:
    pass

Python: n=list(map(int,input().split()))
#print(n)

N=n[0]
a=n[1]
b=n[2]
c=n[3]
d=n[4]

w=(N//a)*b
x=(N//c)*d
y=((N//a)+1)*b
z=((N//c)+1)*d

if (N%a)==0 or (N%c)==0:
    if (N%a)==0 and (N%c)==0:
        if w<=x:
            print(w)
        elif w>x:
            print(x)
    elif (N%c)==0:
        if x<=y:
            print(x)
        elif x>y:
            print(y)
    elif (N%a)==0:
        if w<=z:
            print(w)
        elif w>z:
            print(z)
            

else:
    if y<=z:
        print(y)
    elif y>z:
        print(z)

Python: N,A,B,C,D=map(int,input().split())
x=N//A
if N/A>x:
    x+=1
y=N//C
if N/C>y:
    y+=1
if x*B<y*D:
    print(x*B)
else:
    print(y*D)

Python: # coding: utf-8
n,a,b,c,d = map(int,input().split())

x = (n+a-1)//a * b
y = (n+c-1)//c * d
print(min(x,y))

Python: n,a,b,c,d = map(int,input().split())
print(max(((n-1)//a+1)*b,((n-1)//c+1)*d))

Python: n,a,b,c,d = map(int,input().split())

if n%a == 0:
    x = n//a*b
else:
    x = (n//a+1)*b
    
if n%c ==0:
    y = n//c*d
else:
    y = (n//c+1)*d

if x<=y:
    print(x)
else:
    print(y)

Python: N, A, B, C, D = map(int, input().split())

print(min((N+A-1)//A*B, (N+C-1)//C*D))

Python: N, A, B, C, D = map(int,input().split())
X = N//A + (N%A != 0)*1
Y = N//C + (N%C != 0)*1
print(min(X*B, Y*D))

Python: import math

N, A, B, C, D = list(map(int, input().split(' ')))
price_X = B * math.ceil(N/A)
price_Y = D * math.ceil(N/C)
print(min(price_X, price_Y))

Python: import math
line = input().split(" ")
N = int(line[0])
A = int(line[1])
B = int(line[2])
C = int(line[3])
D = int(line[4])

tmp = 0

A_num = math.ceil(N/A)
C_num = math.ceil(N/C)

if A_num * B < C_num * D:
    print(A_num * B)
else:
    print(C_num * D)

Python: import math
z = list(map(int,input().split()))
N = z[0]
A = z[1]
B = z[2]
C = z[3]
D = z[4]
a = math.ceil(N/A)*B
b = math.ceil(N/C)*D
if a < b:
    print(a)
else:
    print(b)

Python: N,A,B,C,D=list(map(int,input().split()))

if N%A==0: p=N/A

else: p=N//A+1

if N%C==0: q=N/C

else: q=N//C+1

if B*p<D*q: print(int(B*p))
else: print(int(D*q))

Python: # coding: utf-8
# Your code here!
N,A,B,C,D=map(int,input().split());

x=N//A
x1=N%A
if x1>0:
    yen1=(x+1)*B
else:
    yen1=x*B

y=N//C
y1=N%C
if y1>0:
    yen2=(y+1)*D
else:
    yen2=y*D

if yen1>yen2:
    print(yen2)
else:
    print(yen1)

Python: n, a, b, c, d  = map(int, input().split(' '))

X, Y = 0, 0
temp = 0
while temp < n:
    temp += a
    X += b
temp = 0
while temp < n:
    temp += c
    Y += d
print(min(X, Y))

Python: import math

n, a, b, c, d = map(int, input().split())
print(min(math.ceil(n/a) * b, math.ceil(n/c) * d))

Python: N, A, B, C, D = map(int, input().split())
X = N//A + (N%A!=0)*1
Y = N//C + (N%C!=0)*1
print(min(X*B, Y*D))

Python: def get_total(set_num, set_amount):
    total_num = 0
    total_amount = 0
    while True:
        total_num += set_num
        total_amount += set_amount
        if total_num >= num:
            break
    return total_num, total_amount


num, x_num, x_price, y_num, y_price = [int(i) for i in input().split()]

# セットX
x_num, x_amount = get_total(x_num, x_price)

# セットY
y_num, y_amount = get_total(y_num, y_price)

print(x_amount if x_amount < y_amount else y_amount)