A, B, C, D, E = map(int, input().split()) total = A * (B - C) if total == 0: print(0) else: total_cost = 0 current_price = D total_cost += current_price for i in range(2, total + 1): if i % 10 == 0: if current_price >= E: current_price -= E # else, remains the same as before # Update the total cost with the current price total_cost += current_price print(total_cost)