A, B, C, D, E = map(int, input().split()) ans = -10**18 for i in range(C+1): ans = max(ans, A+D*i-(B+E*i)) print(ans)