inf = open("chaos.in", "r")
ouf = open("chaos.out", "w")

A, B, C, D, k = map(int, inf.readline().split())
p = A
for i in range(k):
	A = max(0, min(A * B - C, D))
	if A == p:
		break
	p = A
print(A, file = ouf)
inf.close()
ouf.close()

