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