Vasiliy has a car and he wants to get from home to the post office. The distance which he needs to pass equals to d kilometers.

Vasiliy's car is not new — it breaks after driven every k kilometers and Vasiliy needs t seconds to repair it. After repairing his car Vasiliy can drive again (but after k kilometers it will break again, and so on). In the beginning of the trip the car is just from repair station.

To drive one kilometer on car Vasiliy spends a seconds, to walk one kilometer on foot he needs b seconds (a < b).

Your task is to find minimal time after which Vasiliy will be able to reach the post office. Consider that in every moment of time Vasiliy can left his car and start to go on foot.


-----Input-----

The first line contains 5 positive integers d, k, a, b, t (1 ≤ d ≤ 10^12; 1 ≤ k, a, b, t ≤ 10^6; a < b), where:  d — the distance from home to the post office;  k — the distance, which car is able to drive before breaking;  a — the time, which Vasiliy spends to drive 1 kilometer on his car;  b — the time, which Vasiliy spends to walk 1 kilometer on foot;  t — the time, which Vasiliy spends to repair his car. 


-----Output-----

Print the minimal time after which Vasiliy will be able to reach the post office.


-----Examples-----
Input
5 2 1 4 10

Output
14

Input
5 2 1 4 5

Output
13



-----Note-----

In the first example Vasiliy needs to drive the first 2 kilometers on the car (in 2 seconds) and then to walk on foot 3 kilometers (in 12 seconds). So the answer equals to 14 seconds.

In the second example Vasiliy needs to drive the first 2 kilometers on the car (in 2 seconds), then repair his car (in 5 seconds) and drive 2 kilometers more on the car (in 2 seconds). After that he needs to walk on foot 1 kilometer (in 4 seconds). So the answer equals to 13 seconds.

Source: codeforces | Difficulty: HARD
Tags: Mathematics


Solutions:
(d, k, a, b, t) = map(int, input().split())
time = lambda c: a * c + ((c + k - 1) // k - 1) * t + (d - c) * b
ans = min(time(d), time(min(d, k)))
if d // k > 0:
	ans = min(ans, time(d // k * k))
print(ans)


import sys
import bisect
from bisect import bisect_left as lb
input_ = lambda : sys.stdin.readline().strip('\r\n')
from math import log
from math import gcd
from math import atan2, acos
from random import randint
sa = lambda : input_()
sb = lambda : int(input_())
sc = lambda : input_().split()
sd = lambda : list(map(int, input_().split()))
sflo = lambda : list(map(float, input_().split()))
se = lambda : float(input_())
sf = lambda : list(input_())
flsh = lambda : sys.stdout.flush()
mod = 10 ** 9 + 7
gp = []
cost = []
dp = []
mx = []
ans1 = []
ans2 = []
special = []
specnode = []
a = 0
kthpar = []

def dfs(root, par):
	if par != -1:
		dp[root] = dp[par] + 1
	for i in range(1, 20):
		if kthpar[root][i - 1] != -1:
			kthpar[root][i] = kthpar[kthpar[root][i - 1]][i - 1]
	for child in gp[root]:
		if child == par:
			continue
		kthpar[child][0] = root
		dfs(child, root)
ans = 0

def hnbhai(tc):
	(d, k, a, b, t) = sd()
	if d <= k:
		print(min(a * d, b * d))
		return
	if t + k * a > b * k:
		print(k * a + (d - k) * b)
		return
	car = d // k
	kharcha = k * a
	bacha = d % k
	ans = car * kharcha + (car - 1) * t + min(t + bacha * a, bacha * b)
	print(ans)
for _ in range(1):
	hnbhai(_ + 1)


line = input().split()
d = int(line[0])
k = int(line[1])
a = int(line[2])
b = int(line[3])
t = int(line[4])
if a * k + t > k * b:
	result = d * b
	if a < b:
		result -= k * b
		result += k * a
	if d > k:
		print(result)
	else:
		print(d * min(a, b))
elif k > d:
	print(d * a)
else:
	x = int(d / k)
	y = d - x * k
	t1 = (x - 1) * (a * k + t) + a * k
	print(min(t1 + y * b, t1 + t + y * a))


(d, k, a, b, t) = map(int, input().split())
T = 0
if k >= d:
	print(d * a)
	exit()
if t + a * k >= b * k:
	print(k * a + b * (d - k))
	exit()
else:
	if d % k * a + t < b * (d % k):
		T = d // k * k * a + d % k * a + t * (d // k)
	else:
		T = d // k * k * a + b * (d % k) + t * (d // k - 1)
	print(T)


s = input()
l = s.split(' ')
d = int(l[0])
k = int(l[1])
a = int(l[2])
b = int(l[3])
t = int(l[4])
if d <= k:
	print(d * a)
else:
	car = k * a + t
	foot = k * b
	if foot <= car:
		print(k * a + (d - k) * b)
	else:
		tcar = int(d / k) * car
		dist = d % k
		c1 = tcar + dist * a
		c2 = tcar - t + dist * b
		if dist == 0:
			c1 -= t
		if c1 <= c2:
			print(c1)
		else:
			print(c2)


(d, k, a, b, t) = [int(x) for x in input().split()]
if d <= k:
	print(a * d)
	return
fir = a * k + t - k * b
sec = d * b - k * b + a * k
maxc = d // k - 1
for x in range(maxc - 10, maxc + 10):
	if k * (x + 1) <= d:
		maxc = x
c = maxc
print(min(c * t + c * a * k + k * a + t + a * (d - c * k - k), min(sec, maxc * fir + sec)))


(d, k, a, b, t) = map(int, input().split())
if d <= k:
	print(a * d)
elif t + k * a > k * b:
	print(k * a + (d - k) * b)
else:
	cnt = d // k
	print(k * cnt * a + (cnt - 1) * t + min(t + d % k * a, d % k * b))


def main():
	(d, k, a, b, t) = map(int, input().split())
	res = [d * b]
	if d // k:
		x = d // k * (a * k + t)
		res.append(x + d % k * a)
		res.append(x - t + d % k * b)
		res.append(k * a + (d - k) * b)
	else:
		res.append(d * a)
	print(min(res))
main()


(d, k, a, b, t) = map(int, input().split())
t1 = d * b
t2 = d * a + (d - 1) // k * t
t3 = max(0, d - k) * b + min(k, d) * a
dd = d % k
d1 = d - dd
t4 = d1 * a + max(0, (d1 // k - 1) * t) + dd * b
print(min([t1, t2, t3, t4]))


def main():
	(d, k, a, b, t) = map(int, input().split())
	if k * (b - a) <= t:
		print(min(d, k) * a + max(0, d - k) * b)
	elif d <= k:
		print(a * min(d, k))
	else:
		cnt = (d + k) // k
		price1 = a * k + max(0, (cnt - 2) * (t + k * a)) + t + d % k * a
		price2 = a * k + max(0, (cnt - 2) * (t + k * a)) + d % k * b
		print(min(price1, price2))
main()


(D, K, A, B, T) = map(int, input().split())

def nStops(N):
	if N == 0:
		return 0
	else:
		return (N - 1) // K
case1 = D * B
case2 = A * D + T * nStops(D)
ans = min(case1, case2)
for i in range(max(0, D - 1000000), D + 1):
	ans = min(ans, A * i + B * (D - i) + T * nStops(i))
print(ans)


(d, k, a, b, t) = list(map(int, input().split()))
(dist, time) = (min(d, k), min(d * a, k * a))
if dist < d:
	tstep = min(t + k * a, k * b)
	num_steps = (d - dist) // k
	time += num_steps * tstep
	dist += num_steps * k
	remaining = d - dist
	time += min(t + a * remaining, b * remaining)
print(time)


(d, k, a, b, t) = map(int, input().split())
if d <= k:
	print(d * a)
else:
	d -= k
	res = k * a
	if b * k < a * k + t:
		res += d * b
	else:
		na = d // k
		r = d % k
		res += na * (k * a + t)
		if r > 0:
			if t + r * a < r * b:
				res += t + r * a
			else:
				res += r * b
	print(res)


import sys, io, os, math, copy, pickle
(d, k, a, b, t) = map(int, input().split())
if d <= k:
	print(a * d)
	sys.exit(0)
s = a * k
d -= k
if t + s > b * k:
	print(s + b * d)
	sys.exit(0)
s += d // k * (t + s)
d %= k
print(s + min(b * d, t + a * d))


(d, k, a, b, t) = [int(x) for x in input().split()]
if d <= k:
	print(d * a)
else:
	left = 0
	right = d // k + 1
	if k * b - k * a - t > 0:
		left = (d * (b - a) - (d // k + 1) * t) / (k * b - k * a - t)
	elif k * b - k * a - t < 0:
		right = (d * (b - a) - (d // k + 1) * t) / (k * b - k * a - t)
	N = int(right)
	M = int(left) + 1
	if M >= N:
		print(d * a + d // k * t)
	else:
		if not N < right:
			N = N - 1
		if N > left and M < right:
			A = (N - 1) * t + N * k * a + (d - N * k) * b
			B = (M - 1) * t + M * k * a + (d - M * k) * b
			print(min(A, B))
		else:
			if N > left:
				print((N - 1) * t + N * k * a + (d - N * k) * b)
			if M < right:
				print((M - 1) * t + M * k * a + (d - M * k) * b)


(d, k, a, b, t) = map(int, input().split())
if d <= k:
	print(a * d)
elif a * k + t > k * b:
	print(a * k + (d - k) * b)
else:
	s = d % k
	x = d // k
	if x >= 1:
		im = a * k * x + t * (x - 1)
	else:
		im = 0
	aaa = t + a * s
	bbb = s * b
	im += min(aaa, bbb)
	print(im)


(d, k, a, b, t) = [int(x) for x in input().split()]
N = d // k
p = d % k
if N == 0:
	T = d * a
if N == 1:
	if p * b < t + p * a:
		T = p * b + k * a
	else:
		T = t + p * a + k * a
if N > 1:
	if b * k < t + a * k:
		T = k * a + (d - k) * b
	elif b * p < t + a * p:
		T = N * k * a + (N - 1) * t + p * b
	else:
		T = N * k * a + N * t + p * a
print(T)


from decimal import *
from math import ceil, floor
(d, k, a, b, t) = map(float, input().split())
x = d % k
if k >= d:
	carDist = d
elif b * k < t + a * k:
	carDist = min(k, d)
elif b * x >= t + a * x:
	carDist = d
else:
	x = t / (b - a)
	carDist = max(k, min(d, ceil((d - x) / k) * k))
footDist = d - carDist
count = max(ceil(carDist / k) - 1, 0)
car = carDist * a + count * t
foot = footDist * b
print(int(car + foot))


(d, k, a, b, t) = list(map(int, input().split()))

def main():
	if d <= k:
		return d * a
	else:
		ans = a * k
		p = k
		if b * k <= t + k * a:
			ans += (d - k) * b
		else:
			pp = (d - k) // k
			p += pp * k
			ans += pp * (t + k * a)
			if (d - p) * b < t + (d - p) * a:
				ans += (d - p) * b
			else:
				ans += t + (d - p) * a
		return ans
print(main())


(d, k, a, b, t) = map(int, input().split(' '))
cyc = (d + k - 1) // k
alldrive = d * a + t * (cyc - 1)
allwalk = d * b
minn = min(alldrive, allwalk)
if (d + k - 1) // k <= 10:
	for x in range(1, (d + k - 1) // k):
		time = x * k * a + (x - 1) * t + b * (d - x * k)
		minn = min(minn, time)
else:
	for x in [1, (d + k - 1) // k - 1]:
		time = x * k * a + (x - 1) * t + b * (d - x * k)
		minn = min(minn, time)
print(minn)


(d, k, a, b, t) = map(int, input().split())
if k >= d:
	print(a * d)
else:
	n = d - (k - 1) * d // k
	x = (n - 1) * t + d * a
	y = d * b
	p = a * k + (d - k) * b
	i = n - 1
	q = (i - 1) * t + i * k * a + (d - i * k) * b
	print(min(x, y, p, q))


from random import randint
(d, k, a, b, t) = map(int, input().split())
cnt = (d + k - 1) // k

def get(m):
	if k * m >= d:
		return d * a + (cnt - 1) * t
	return k * m * a + max(0, m - 1) * t + (d - k * m) * b

def solvefast():
	if k >= d:
		return d * a
	else:
		l = 0
		r = cnt + 2
		while r - l > 2:
			m1 = l + r >> 1
			m2 = m1 + 1
			if get(m2) > get(m1):
				r = m2
			else:
				l = m1
		mn = 10 ** 20
		for i in range(max(l - 13, 0), min(l + 13, cnt + 3)):
			mn = min(mn, get(i))
		return mn
print(solvefast())


import sys
(d, k, a, b, t) = input().split()
(d, k, a, b, t) = (int(d), int(k), int(a), int(b), int(t))
if d <= k:
	if a > b:
		print(b * d)
	else:
		print(a * d)
elif a * k + t >= b * k:
	if a < b:
		print((d - k) * b + k * a)
	else:
		print(d * b)
else:
	q = d // k
	m = d % k
	ans = q * (a * k + t) - t
	if m * b <= t + m * a:
		ans = ans + m * b
	else:
		ans = ans + t + m * a
	print(ans)


def fun(d, k, a, b, t):
	dv = d // k
	return min(a * k + b * (d - k), a * k * dv + t * (dv - 1))
(d, k, a, b, t) = map(int, input().split(' '))
if d <= k:
	print(a * d)
	exit()
if d % k == 0:
	print(fun(d, k, a, b, t))
elif a * k + t < b:
	print(a * k + b * (d - k))
else:
	dv = d // k
	left = d - dv * k
	last = d - left
	get = fun(last, k, a, b, t)
	print(min(get + b * left, get + t + a * left))


import sys
(d, k, a, b, t) = list(map(int, input().split()))
mn = 10000000000000
if d <= k:
	print(a * d)
	return
s = a * k
d -= k
if t + s > b * k:
	print(s + b * d)
	return
s += d // k * (t + s)
d %= k
print(s + min(d * b, t + d * a))


from math import *
(d, k, a, b, t) = [int(x) for x in input().split()]
ans = 0
if d <= k:
	ans = d * a
elif t + k * a > k * b:
	ans = k * a + (d - k) * b
else:
	cnt = floor(d / k)
	ans = k * cnt * a + (cnt - 1) * t + min(t + d % k * a, d % k * b)
print(int(ans))


import sys
(d, k, a, b, t) = map(int, input().split())
mn = 10000000000000
if d <= k:
	print(a * d)
	sys.exit(0)
s = a * k
d -= k
if t + s > b * k:
	print(s + b * d)
	sys.exit(0)
s += d // k * (t + s)
d %= k
print(s + min(d * b, t + d * a))


(d, k, a, b, t) = [int(i) for i in input().split()]
if k >= d:
	print(d * a)
elif t + k * a >= k * b:
	print(d * b + k * a - k * b)
else:
	x = d // k
	print(x * k * a + t * (x - 1) + min((d - k * x) * b, t + (d - k * x) * a))


import sys, io, os, math, copy, pickle
(d, k, a, b, t) = list(map(int, input().split()))
if d <= k:
	print(a * d)
	return
s = a * k
d -= k
if t + s > b * k:
	print(s + b * d)
	return
s += d // k * (t + s)
d %= k
print(s + min(b * d, t + a * d))


from sys import stdin, stdout
(d, k, a, b, t) = map(int, stdin.readline().split())
ans = 0
if k * b > k * a + t:
	if k < d:
		ans += (d // k - 1) * t + (d - d % k) * a
		d %= k
		if d * a + t < d * b:
			ans += d * a + t
		else:
			ans += d * b
	else:
		ans += a * d
elif k < d:
	ans = (d - k) * b + k * a
else:
	ans = d * a
stdout.write(str(ans))


(d, k, a, b, t) = list(map(int, input().split()))
T = 0
if k >= d:
	print(d * a)
	return
if t + a * k >= b * k:
	print(k * a + b * (d - k))
	return
else:
	if d % k * a + t < b * (d % k):
		T = d // k * k * a + d % k * a + t * (d // k)
	else:
		T = d // k * k * a + b * (d % k) + t * (d // k - 1)
	print(T)


(d, k, a, b, t) = tuple(map(int, input().split()))
if d > k:
	dist = d - k
	s = k * a
	if t + k * a <= k * b:
		s = s + dist // k * (t + k * a)
		dist = dist % k
	else:
		s = s + dist * b
		dist = 0
	if t + dist * a > dist * b:
		s = s + dist * b
	else:
		s = s + t + dist * a
	print(s)
else:
	print(d * a)


list1 = list(map(int, input().split()))
d = list1[0]
k = list1[1]
a = list1[2]
b = list1[3]
t = list1[4]
if d < k:
	print(d * a)
elif (a * k + t) / k > b:
	print((d - k) * b + k * a)
else:
	d1 = d % k
	if d1 * a + t > d1 * b:
		print(a * k * (d // k) + t * (d // k - 1) + d % k * b)
	else:
		print((a * k + t) * (d // k) + d1 * a)


def get_less_multply(d, k):
	r = d // k
	res = k * r
	if res == d:
		return res - k
	return res
line = input().split()
d = int(line[0])
k = int(line[1])
a = int(line[2])
b = int(line[3])
t = int(line[4])
if d <= k:
	print(a * d)
else:
	only_foot = b * (d - k) + a * k
	dl = get_less_multply(d, k)
	Tl = dl / k * (a * k + t)
	only_car = Tl + (d - dl) * a
	dll = get_less_multply(dl, k)
	Tll = dll / k * (a * k + t)
	last_car = Tll + k * a
	foot = (d - dl) * b
	mini = min(only_car, last_car + foot, only_foot)
	print(mini)


(d, k, a, b, t) = map(int, input().split())
if d <= k:
	print(a * d)
	exit()
s = a * k
d -= k
if b * k <= t + s:
	print(s + b * d)
	exit()
s += d // k * (t + s)
d %= k
print(s + min(b * d, t + a * d))


import collections
import functools
import math
import random
import sys
import bisect
input = sys.stdin.readline

def In():
	return map(int, sys.stdin.readline().split())

def rdpost():
	(d, mcar, cs, fs, rp) = In()
	if d <= mcar:
		return cs * d
	if rp + mcar * cs > mcar * fs:
		return mcar * cs + (d - mcar) * fs
	time = (d // mcar - 1) * (cs * mcar + rp) + cs * mcar
	last = d % mcar
	return time + min(rp + last * cs, last * fs)
print(rdpost())


(d, k, a, b, t) = map(int, input().split())
if d <= k:
	print(d * a)
elif t + k * a > k * b:
	print(k * a + (d - k) * b)
else:
	cnt = d // k
	s = k * a
	dd = d % k
	ans = cnt * s + (cnt - 1) * t + min(t + dd * a, dd * b)
	print(ans)


import math
(d, k, a, b, t) = map(int, input().split())
distance = a * t / ((b - a) * b) + t / b
time = 0
n = math.ceil((d - distance) / k)
if k > d:
	print(d * a)
	exit(0)
if k < distance:
	time = k * a + (d - k) * b
	print(time)
	exit(0)
if n * k >= d:
	time = a * d + d // k * t
	if d % k == 0:
		time -= t
else:
	time = n * k * a + (n - 1) * t + (d - n * k) * b
print(time)


(d, k, a, b, t) = map(int, input().split())
x = d // k
u = (a - b) * k + t
v = b * d - t

def solve():
	if x == 0:
		return a * d
	if u >= 0:
		return min(u + v, d * b)
	else:
		return min(u * x + v, min(a * d + x * t, d * b))
print(solve())


(d, k, a, b, t) = map(int, input().split())
if a >= b:
	print(b * d)
elif k >= d:
	print(a * d)
elif a * k + t <= b * k:
	interval = d // k
	if d % k == 0:
		interval -= 1
	print(min(a * d + interval * t, a * (d - d % k) + (d // k - 1) * t + d % k * b))
else:
	print(k * a + (d - k) * b)


(d, k, a, b, t) = map(int, input().split())
if k <= d:
	ans = a * k + (d // k - 1) * min(t + a * k, b * k) + min(d % k * a + t, d % k * b)
	print(ans)
else:
	print(d * a)


(d, k, a, b, t) = [int(i) for i in input().split()]
if k > d:
	print(a * d)
elif k * a + t > k * b:
	if d > k:
		print(k * a + (d - k) * b)
	else:
		print(d * a)
else:
	count = 0
	left = d % k
	count += int(d / k) * (a * k + t) - t
	count += min(left * b, left * a + t)
	print(count)


import math
import re
(d, k, a, b, t) = map(int, input().split())
if d <= k:
	res = d * a
else:
	d -= k
	res = k * a
	if k * b < k * a + t:
		res += d * b
	else:
		res += d // k * (k * a + t)
		res += min(d % k * b, t + a * (d % k))
print(res)


from math import ceil
(d, k, a, b, t) = (int(t) for t in input().split())

def time(d, k, a, b, t, x):
	return x * a + (d - x) * b + t * (ceil(x / k) - 1)
if d < k:
	x = d
elif time(d, k, a, b, t, k) <= time(d, k, a, b, t, 2 * k):
	x = k
elif time(d, k, a, b, t, d // k * k) < time(d, k, a, b, t, d):
	x = d // k * k
else:
	x = d
print(time(d, k, a, b, t, x))


def easy(vals):
	d = int(vals[0])
	k = int(vals[1])
	a = int(vals[2])
	b = int(vals[3])
	t = int(vals[4])
	if d <= k:
		return d * a
	sofar = k * a
	left = d - k
	if b * k < a * k + t:
		return sofar + left * b
	if left > k:
		sofar = sofar + left // k * (a * k + t)
		left = left % k
	if left * b <= left * a + t:
		return sofar + left * b
	return sofar + left * a + t
vals = input().split()
print(easy(vals))


(d, k, a, b, t) = list(map(int, input().split()))
if d <= k:
	print(a * d)
	return
s = a * k
d -= k
if b * k <= t + s:
	print(s + b * d)
	return
s += d // k * (t + s)
d %= k
print(s + min(b * d, t + a * d))


import sys
(d, k, a, b, t) = map(int, input().split())
if d <= k:
	print(d * a)
	exit()
d -= k

def solve1():
	x = (d + k - 1) // k
	return t * x + a * d

def solve2():
	x = d // k
	y = d % k
	return (t + a * k) * x + b * y

def solve3():
	return d * b
print(min(solve1(), solve2(), solve3()) + a * k)


(d, k, a, b, t) = [int(s) for s in input().split()]
ans = d * b
n = d // k
if d <= k:
	ans = ans = d * a
elif t + a * k > k * b:
	ans = k * a + (d - k) * b
else:
	ans = n * k * a + (n - 1) * t + min(t + d % k * a, d % k * b)
print(ans)


(d, k, a, b, t) = map(int, input().split())
if a * k + t > k * b:
	result = d * b
	if a < b:
		result -= k * b
		result += k * a
	if d > k:
		print(result)
	else:
		print(d * min(a, b))
elif k > d:
	print(d * a)
else:
	x = int(d / k)
	y = d - x * k
	t1 = (x - 1) * (a * k + t) + a * k
	print(min(t1 + y * b, t1 + t + y * a))


def f(x, d, k, a, b, t):
	return x * (t + k * a - k * b) + b * d - t
(d, k, a, b, t) = map(int, input().split())
X = d // k
if X < 1:
	print(d * a)
elif t + k * a - k * b < 0:
	print(min(X * t + d * a, f(X, d, k, a, b, t)))
else:
	print(min(d * b, f(1, d, k, a, b, t)))


[d, k, a, b, t] = [int(x) for x in input().split()]
time = min(d, k) * a
d -= k
if d > k:
	if t + a * k > b * k:
		time += (d - d % k) * b
	else:
		time += (d - d % k) * a + d // k * t
	d = d % k
if d <= 0:
	print(time)
else:
	if t + a * d > b * d:
		time += d * b
	else:
		time += d * a + t
	print(time)


import sys
from bisect import bisect_right as rb
from collections import deque
from queue import PriorityQueue
input_ = lambda : sys.stdin.readline().strip('\r\n')
ii = lambda : int(input_())
il = lambda : list(map(int, input_().split()))
ilf = lambda : list(map(float, input_().split()))
ip = lambda : input_()
fi = lambda : float(input_())
ap = lambda ab, bc, cd: ab[bc].append(cd)
li = lambda : list(input_())
pr = lambda x: print(x)
prinT = lambda x: print(x)
f = lambda : sys.stdout.flush()
inv = lambda x: pow(x, mod - 2, mod)
mod = 10 ** 9 + 7
for _ in range(1):
	(d, k, a, b, t) = il()
	if d <= k:
		print(d * a)
		continue
	if t + k * a > k * b:
		print(k * a + (d - k) * b)
		continue
	c = d // k
	s = k * a
	e = d % k
	ans = c * s + ((c - 1) * t + min(t + e * a, e * b))
	print(ans)


import bisect
from itertools import accumulate
import os
import sys
import math
from decimal import *
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def SieveOfEratosthenes(n):
	prime = []
	primes = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if primes[p] == True:
			prime.append(p)
			for i in range(p * p, n + 1, p):
				primes[i] = False
		p += 1
	return prime

def primefactors(n):
	fac = []
	while n % 2 == 0:
		fac.append(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 2):
		while n % i == 0:
			fac.append(i)
			n = n // i
	if n > 1:
		fac.append(n)
	return fac

def factors(n):
	fac = set()
	fac.add(1)
	fac.add(n)
	for i in range(2, int(math.sqrt(n)) + 1):
		if n % i == 0:
			fac.add(i)
			fac.add(n // i)
	return list(fac)

def modInverse(a, m):
	m0 = m
	y = 0
	x = 1
	if m == 1:
		return 0
	while a > 1:
		q = a // m
		t = m
		m = a % m
		a = t
		t = y
		y = x - q * y
		x = t
	if x < 0:
		x = x + m0
	return x
(d, k, a, b, t) = map(int, input().split())
if k >= d:
	print(d * a)
elif t + k * a > k * b:
	print(k * a + (d - k) * b)
else:
	distance = d // k
	ans = distance * k * a + (distance - 1) * t + min(t + d % k * a, d % k * b)
	print(ans)


(d, k, a, b, t) = map(int, input().split())
f = lambda x: (a - b) * x + b * d + t * int(max(0, x - 1) // k)

def f(x):
	xk = (x - 1) // k
	if xk <= 0:
		xk = 0
	return (a - b) * x + b * d + t * xk
ans = f(d)
MX = 6 * k
for i in range(0, min(d + 1, MX + 1)):
	ans = min(ans, f(i))
print(ans)


import sys
from math import *
(d, k, a, b, t) = map(int, input().split())
if d < k:
	print(d * a)
	exit()
if t + k * a > k * b:
	print(k * a + (d - k) * b)
	exit()
cnt = int(d / k)
print(k * a * cnt + (cnt - 1) * t + min(t + d % k * a, d % k * b))


(d, k, a, b, t) = map(int, input().split(' '))
if d <= k:
	print(d * a)
	exit(0)
ans = a * k + (d - k) * b
dd = d // k * k
rr = d % k
ans = min(ans, a * dd + (d // k - 1) * t + min(t + a * rr, b * rr))
print(ans)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import sys

def array():
	return list(map(int, sys.stdin.readline().split()))

def intt():
	return map(int, sys.stdin.readline().split())

def inp():
	return int(input())
from itertools import permutations as pmt
from collections import Counter
from collections import Counter
from collections import deque
(d, k, a, b, t) = map(int, input().split())
if d <= k:
	print(d * a)
else:
	ans = 0
	ans += k * a
	if t + k * a > k * b:
		ans += (d - k) * b
	else:
		cnt = (d - k) // k
		ans += t * cnt + cnt * k * a
		ans += min(t + d % k * a, d % k * b)
	print(ans)


def main():
	(d, k, a, b, t) = map(int, input().split())
	ans = 0
	dc = d // k
	dr = d % k
	if not dc:
		print(a * dr)
	else:
		way1 = dc * (k * a + t) + dr * a
		way2 = dc * (k * a + t) - t + dr * b
		way3 = k * a + (d - k) * b
		print(min(way1, way2, way3))
main()


(dist, car, drive, walk, repair) = map(int, input().split())
if dist > car:
	left = dist - car
	s = car * drive
	if repair + car * drive <= car * walk:
		s += left // car * (repair + car * drive)
		left %= car
	else:
		s += left * walk
		left = 0
	if repair + left * drive > left * walk:
		s += left * walk
	else:
		s += repair + left * drive
	print(s)
else:
	print(dist * drive)