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==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
    
if X<Y:
    print(X)
else:
    print(Y)

Python: # coding: utf-8
# Your code here!

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())
import math
x=math.ceil(N/A)
y=math.ceil(N/C)

if x*B<y*D:
    print(x*B)
elif x*B>y*D:
    print(y*D)
else:
    print(x*B)

Python: N,a,b,c,d=map(int,input().split())
x=-(-N//a)
y=b*x

z=-(-N//c)
l=d*z
if y<=l:
    print(y)
else:
    print(l)

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

## setX
if N % A == 0 :
    X = N // A * B
else : 
    X = (N // A + 1) * B

## setY
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())
x = 0
y = 0
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: import math
n,a,b,c,d=map(int,input().split())
q=math.ceil(n/a)*b
w=math.ceil(n/c)*d
print(min(q,w))

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:
    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(y)
else:
    print(x)

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

if X==(N/A)*B and Y==(N/C)*D:
    if X<Y:
        print(X)
    else:
        print(Y)
elif X==(N/A)*B and Y!=(N/C)*D:
    if X<(Y+D):
        print(X)
    else:
        print(Y+D)
elif X!=(N/A)*B and Y==(N/C)*D:
    if X+B<Y:
        print(X+B)
    else:
        print(Y)
elif X!=(N/A)*B and Y!=(N/C)*D:
    if X+B<Y+D:
        print(X+B)
    else:
        print(Y+D)

Python: import math
N,A,B,C,D=map(int,input().split())
if (D*math.ceil((N/C)))>(B*math.ceil((N/A))) :
    print(B*math.ceil((N/A)))
else : 
    print(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

if n % c == 0:
    y = n // c
else:
    y = n // c + 1

ans = min(x * b, y * d)
print(ans)

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=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: 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(Y)
elif Y>X:
    print(X)
else:
    print(Y)

Python: n,a,b,c,d=input().split()
n=int(n)
a=int(a)
b=int(b)
c=int(c)
d=int(d)
pricea=((n+a-1)//a)*b
pricec=((n+c-1)//c)*d
if pricea>pricec:
    print(pricec)
else:
    print(pricea)

Python: n,a,b,c,d=map(int,input().split())
x=n//a*b
y=n//c*d
if n%a!=0:
    x+=b
if n%c!=0:
    y+=d
print(min(x,y))

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

x = math.ceil(N/A)
x_t = B * x 
y = math.ceil(N/C)
y_t = D * y

print(min(x_t, y_t))

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

if math.ceil(N/A)*B >= math.ceil(N/C)*D:
    print(math.ceil(N/C)*D)
else:
    print(math.ceil(N/A)*B)

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

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

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

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

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

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

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

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

X=B*a
Y=D*b

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

Python: import math
N,A,B,C,D=map(int,input().split())
if (D*math.ceil((N/C)))>(B*math.ceil((N/A))) :
    print(B*math.ceil((N/A)))
else : 
    print(D*math.ceil((N/C)))

Python: # coding: utf-8
from math import ceil
N,A,B,C,D = map(int,input().split())   #N A B C D
if ceil(N/A)*B > ceil(N/C)*D:
    print(ceil(N/C)*D)
elif ceil(N/C)*D > ceil(N/A)*B :
    print(ceil(N/A)*B)
else:
    print(ceil(N/A)*B)

Python: import math
N,A,B,C,D=map(int,input().split())
a=N/A
c=N/C
x=math.ceil(a)
y=math.ceil(c)
u= x * B
w= y * D
if u>w:
    print(w)
else:
    print(u)

Python: inputed_str = input()
str_list = inputed_str.split(' ')
data = [int(i) for i in str_list]
target = data[0]
def how_much(a, b):
    sumnum = 0
    summoney = 0
    while sumnum < target:
        sumnum += a
        summoney += b 
    return summoney

x = how_much(data[1], data[2])
y = how_much(data[3], data[4])
print(max(x, y))

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

currentPen = 0
costA = 0
costB = 0
while (n > currentPen):
  costA += b
  currentPen += a

currentPen = 0
while(n > currentPen):
  costB += d
  currentPen += c

if (costA < costB):
  print(costA)
else:
  print(costB)

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

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

Python: N, A, B, C, D = (int(x) for x in input().split())

if N%A==0:
    x = N//A
if N%A>0:
    x = (N//A)+1
if N%C==0:
    y = N//C
if N%C>0:
    y = (N//C)+1

if B*x<=D*y:
    print(B*x)
if D*y<B*x:
    print(D*y)

Python: import math
N,A,B,C,D = map(int,input().split())
v = math.ceil(N/A)*B
w = math.ceil(N/C)*D
if v > w:
    print(w)
else:
    print(v)

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

a=int(N//A)
c=int(N//C)
if N%A==0:
    a=a
else:
    a=a+1
if N%C==0:
    c=c
else:
    c=c+1
    

x=a*B
y=c*D

if x>=y:
    print(int(y))
else:
    print(int(x))

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

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

Python: # coding: utf-8
# Your code here!

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

a = N/A
x = math.ceil(a)
X = x*B

c = N/C
y = math.ceil(c)
Y = y*D

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

Python: import math
N,A,B,C,D=(int(x) for x in input().split())

if math.ceil(N/A)*B<math.ceil(N/C)*D:
    print(math.ceil(N/A)*B)
else:
    print(math.ceil(N/C)*D)