Go: package main

import (
	"fmt"
	"os"
	"strconv"
	"bufio"
	"strings"
)
func main2(){
ans(10,3,50,4,60)
ans(10 ,3, 100, 5, 180)//360
ans(6, 2, 200, 3, 300)// 600

}

func main() {



    sc := bufio.NewScanner(os.Stdin)
     sc.Scan()
        args := strings.Split(sc.Text(), " ")
      

	var n, a, b, c, d int

	n, _ = strconv.Atoi(args[0])
	a, _ = strconv.Atoi(args[1])
	b, _ = strconv.Atoi(args[2])
	c, _ = strconv.Atoi(args[3])
	d, _ = strconv.Atoi(args[4])

        ans(n,a,b,c,d)
}

func ans(n,a,b,c,d int){

	ans2 := 0
	for i := 0; i < 1000; i++ {
		if i*a >= n {
			ans2 = i * b
			break
		}
	}

	for i := 0; i < 1000; i++ {
	
		if i*c >= n {
			if ans2 > i*d {


				ans2 = i *  d
			}
			break
		}
	}

	fmt.Printf("%d\n", ans2)
}

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

Python: N,A,B,C,D=map(int,input().split())
a=N//A
b=N%A
if b==0:a=a
else:a=a+1
c=N//C
d=N%C
if d==0:c=c
else:c=c+1
E=a*B
F=c*D
if E>F:print(F)
else:print(E)

Python: try:
     (N,a,b,c,d)  =  map(int,input().split())
except:
    exit
cnt = 0
min_cost = 1000000

while ( (cnt * a) < N + a):
    a_setnum = cnt 
    zan = N - (a_setnum * a) 
    if (zan < 0):
        zan = 0
    c_setnum = zan // c
    if ( zan % c != 0):
        c_setnum += 1
    cnt += 1
    cost =a_setnum * b + c_setnum *d
    if (min_cost > cost):
        min_cost = cost
print (min_cost)

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())
import math
a = B*math.ceil(N/A)
b = D*math.ceil(N/C)
if a>b:
    print(b)
else:
    print(a)

Python: N, A, B, C, D = list(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: N,A,B,C,D = map(int, input().split())
X = N//A
Y = N//C
S = (N//A)+1
T = (N//C)+1

if (N%A)==0:
    if (N%C)==0:
        print(min(X*B, Y*D))
    else:
        print(min(X*B, T*D))
else:
    if (N%C)==0:
        print(min(S*B, Y*D))
    else:
        print(min(S*B, T*D))

Python: N, A, B, C, D = map(int,input().split())
 
Px = N // A
Py = N // C
if Px * A >= N:
    pass
else:
    Px = Px + 1

if Py * C >= N:
    pass
else:
    Py = Py + 1

Vx = Px * B
Vy = Py * D
if Vx >= Vy:
    print(Vy)
else :
    print(Vx)

Python: a=list(map(int,input().split()))
n=1
while True:
    if a[1]*n >= a[0]:
        x=a[2]*n
        break
    n += 1
m=1
while True:
    if a[3]*m >= a[0]:
        y=a[4]*m
        break
    m += 1
z=[x,y]
w=sorted(z)
print(w[0])

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
    
print(min(x*B,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: n,a,b,c,d=map(int,input().split())
x=n//a
if n%a!=0:
    x+=1
a=x*b
y=n//c
if n%c!=0:
    y+=1
c=y*d
if a<c:
    print(a)
else:
    print(c)

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

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
if x*a < n:
    x += 1
x *= b

y = n//c
if y*c < n:
    y += 1
y *= d

print(min(x,y))

Python: import math

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

print(min(B*math.ceil(N/A), D*math.ceil(N/C)))

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

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

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

if s1<=s2:
    print(s1)
else:
    print(s2)

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

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

if X < Y:
    print(X)
else:
    print(Y)

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

if N % A == 0:
    a = N // A
else:
    a = N // A + 1

if N % C == 0:
    c = N // C
else:
    c = N // C + 1

x = a * B
y = c * D

print(min(x,y))

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

Python: import math
N,A,B,C,D=(int(x) for x in input().split())
if 1<=N<=1000 and 1<=A<=1000 and 1<=B<=1000 and 1<=C<=1000 and 1<=D<=1000:
   if math.ceil(N/A)*B<math.ceil(N/C)*D:
      print(math.ceil(N/A)*B)
   else:
      print(math.ceil(N/C)*D)
else:
   pass

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

if N % C == 0:
    c = y * D
else:
    c = D * (y + 1)
    
if a < c:
    print(a)
else:
    print(c)

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
print(min(X,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=(int(x) for x in input().split())

x=N//A
if N%A>0:
    x=x+1

y=N//C
if N%C>0:
    y=y+1
    
if x*B<=y*D:
    print(x*B)
else:
    print(y*D)

Python: N,A,B,C,D=map(int,input().split())
m=(N//A)*B
n=((N//A)+1)*B
s=(N//C)*D
t=((N//C)+1)*D
if N%A == 0 and N%C == 0:
    if m < s:
        print(m)
    else:
        print(s)
elif N%A == 0 and N%C >=1:
    if m < t:
        print(m)
    else:
        print(t)
elif N%A >= 1 and N%C == 0:
    if n < s:
        print(n)
    else:
        print(s)
elif N%A >= 1 and N%C >= 1:
    if n < t:
        print(n)
    else:
        print(t)

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

Python: inp = list(map(int, input().split()))
n = inp[0]
X = inp[1:3]
Y = inp[3:5]

if n % X[0] == 0:
    costx = 0
else:
    costx = 1
    
if n % Y[0] == 0:
    costy = 0
else:
    costy = 1
x = (n//X[0] + costx)*X[1]
y = (n//Y[0] + costy)*Y[1]
print(min(x,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())
if N % A == 0 and N % C == 0 and B / A < D / C:
    print(N//A*B)
elif N % A == 0 and N % C == 0 and B / A >= D / C: 
    print(N//C*D)
elif N % A != 0 and N % C == 0 and (N//A+1)*B < N//C*D :
    print((N//A+1)*B)
elif N % A != 0 and N % C == 0 and (N//A+1)*B >= N//C*D:
    print(N//C*D)
elif N % A == 0 and N % C != 0 and N//A*B < (N//C+1)*D:
    print(N//A*B)
elif N % A == 0 and N % C != 0 and N//A*B >= (N//C+1)*D:
    print((N//C+1)*D)
elif N % A != 0 and N % C != 0 and (N//A+1)*B < (N//C+1)*D :
    print((N//A+1)*B)
elif N % A != 0 and N % C != 0 and (N//A+1)*B >= (N//C+1)*D :
    print((N//C+1)*D)
else :
    pass

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

Python: import math
import sys

x, a, b, c, d = list(map(int, sys.stdin.readline().split()))

p = math.ceil(x/a)*b
q = math.ceil(x/c)*d

if p < q:
    print(p)
else:
    print(q)

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))