a, b, c, d, e = map(int, input().split()) ans = -10 ** 9 for _ in range(c+1): ans = max(ans, a - b) a += d b += e print(ans)