A bakery baked 30 loaves of bread in the morning. By lunchtime, they sold 18 loaves. In the afternoon, they baked another 12 loaves. How many loaves of bread does the bakery have left by the end of the day, assuming no additional sales? Let's think step by step and output the final answer within \boxed{}.
user