a, b, c, d, e = map(int, input().split()) happy_max = -1 * 10**9 for x in range(c+1): taste = a + x * d cal = b + x * e happy = taste - cal happy_max = max(happy_max, happy) print(happy_max)