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

a, b, c, d, k = map(int, inf.readline().split())

while k > 0:
    a = max(0, min(a * b - c, d))
    if a == d or a == 0:
        break
    k -= 1

print(a, file = ouf)