a,b,c,d,e = map(int,input().split()) mx = 0 for i in range(c): tmp = a-b + i*d - i*e mx = max(tmp,mx) print(mx)