Sam drives from his house to the grocery store, which is 8 miles away. After shopping, he drives from the grocery store to his friend's house, which is 5 miles away. Finally, he drives back home from his friend's house, which is 10 miles away. How many miles did Sam drive in total? Let's think step by step and output the final answer within \boxed{}.
user