a, b, c, d, e = 5.times.map { gets.to_i }
time = 0

condition = if a.negative?
              'frozen'
            else
              'raw'
            end

if condition == 'frozen'
  time += -a * c
  time += d
  time += e * b
end

time += e * (b - a) if condition == 'raw'

p time

