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