a,b,c,d,e = map(int, input().split()) happyValList = [] for i in range(0, c+1): happyVal = (a + i*d) - (b + i*e) happyValList.append(happyVal) print(max(happyValList))