events = input().split("|")
energy = 100
coins = 100
is_fine = True
for c in events:
state, amount = c.split("-")
amount = int(amount)
if state == "rest":
if energy + amount > 100:
gained = 100 - energy
else:
gained = amount
energy += gained
print(f'You gained {gained} energy.')
print(f'Current energy: {energy}.')
elif state == "order":
energy -= 30
if energy > 0:
coins += amount
print(f'You earned {amount} coins.')
else:
energy = 0
energy += 50
print("You had to rest!")
else:
coins -= amount
if coins > 0:
print(f"You bought {state}.")
else:
print(f'Closed! Cannot afford {state}.')
is_fine = False
break
if is_fine:
print(f'Day completed!')
print(f"Coins: {coins}")
print(f'Energy: {energy}')